Skip to content

Commit

Permalink
Merge pull request #17 from estrizhok/main
Browse files Browse the repository at this point in the history
Added MeansTestSubjectAttribute attribute.
  • Loading branch information
controlflow committed May 11, 2023
2 parents 7a6b096 + 78d0866 commit 72b5348
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Annotations.cs
Expand Up @@ -1865,5 +1865,32 @@ public TestSubjectAttribute([NotNull] Type subject)
}
}

/// <summary>
/// Signifies a generic argument as the test subject for a test class.
/// </summary>
/// <remarks>
/// The <see cref="MeansTestSubjectAttribute"/> can be applied to a generic parameter of a base test class to indicate that
/// the type passed as the argument is the class being tested. This information can be used by an IDE to provide better
/// navigation support or by test runners to group tests by subject and to provide better test reports.
/// </remarks>
/// <example><code>
/// public class BaseTestClass&lt;[MeansTestSubject] T&gt;
/// {
/// protected T Component { get; }
/// }
///
/// public class CalculatorAdditionTests : BaseTestClass&lt;Calculator&gt;
/// {
/// [Test]
/// public void Should_add_two_numbers()
/// {
/// Assert.That(Component.Add(2,3 ), Is.EqualTo(5));
/// }
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.GenericParameter)]
[Conditional("JETBRAINS_ANNOTATIONS")]
public sealed class MeansTestSubjectAttribute : Attribute { }

#endregion
}

0 comments on commit 72b5348

Please sign in to comment.