< Summary

Information
Class: ArturRios.Util.Test.Attributes.CustomFactAttribute
Assembly: ArturRios.Util.Test
File(s): D:\Repositories\dotnet-test-util\src\Attributes\CustomFactAttribute.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 37
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage
100%
Covered methods: 3
Fully covered methods: 2
Total methods: 3
Method coverage: 100%
Full method coverage: 66.6%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%22100%
get_TestType()100%11100%
get_Environments()100%11100%

File(s)

D:\Repositories\dotnet-test-util\src\Attributes\CustomFactAttribute.cs

#LineLine coverage
 1using ArturRios.Configuration.Enums;
 2using Xunit;
 3using Xunit.Sdk;
 4
 5namespace ArturRios.Util.Test.Attributes;
 6
 7/// <summary>
 8/// Base <see cref="FactAttribute"/> that can skip a test based on the active <c>ASPNETCORE_ENVIRONMENT</c>
 9/// or an explicit condition, and stamps its <see cref="TestType"/> as the <c>Category</c> trait.
 10/// Derive from it to create environment-aware fact attributes filterable by test type.
 11/// </summary>
 12[TraitDiscoverer("ArturRios.Util.Test.Attributes.TestTypeTraitDiscoverer", "ArturRios.Util.Test")]
 13public class CustomFactAttribute : FactAttribute, ITraitAttribute
 14{
 15    /// <summary>Creates the attribute and applies the skip reason, if any.</summary>
 16    /// <param name="testType">The kind of test this attribute marks, published as the <c>Category</c> trait.</param>
 17    /// <param name="environments">Environments in which the test must not run. <c>null</c> imposes no restriction.</par
 18    /// <param name="skipCondition">When <c>true</c>, the test is skipped regardless of the environment.</param>
 1219    protected CustomFactAttribute(TestType testType, EnvironmentType[]? environments = null, bool skipCondition = false)
 1220    {
 1221        TestType = testType;
 1222        Environments = environments;
 23
 1224        var reason = EnvironmentSkip.GetReason(environments, skipCondition);
 25
 1226        if (reason is not null)
 527        {
 528            Skip = reason;
 529        }
 1230    }
 31
 32    /// <summary>The kind of test this attribute marks, published as the <c>Category</c> trait.</summary>
 433    public TestType TestType { get; }
 34
 35    /// <summary>The environments in which the test must not run, or <c>null</c> when unrestricted.</summary>
 136    public EnvironmentType[]? Environments { get; }
 37}