< Summary

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

Metrics

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

File(s)

D:\Repositories\dotnet-test-util\src\Attributes\CustomTheoryAttribute.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="TheoryAttribute"/> 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 theory attributes filterable by test type.
 11/// </summary>
 12[TraitDiscoverer("ArturRios.Util.Test.Attributes.TestTypeTraitDiscoverer", "ArturRios.Util.Test")]
 13public class CustomTheoryAttribute : TheoryAttribute, 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>
 619    protected CustomTheoryAttribute(TestType testType, EnvironmentType[]? environments = null, bool skipCondition = fals
 620    {
 621        TestType = testType;
 622        Environments = environments;
 23
 624        var reason = EnvironmentSkip.GetReason(environments, skipCondition);
 25
 626        if (reason is not null)
 127        {
 128            Skip = reason;
 129        }
 630    }
 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>
 036    public EnvironmentType[]? Environments { get; }
 37}