From 78d0866369a510beb5a91ec11824d509fddedb26 Mon Sep 17 00:00:00 2001 From: Eugene Strizhok Date: Wed, 10 May 2023 13:50:02 +0200 Subject: [PATCH] Added MeansTestSubjectAttribute attribute. --- src/Annotations.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Annotations.cs b/src/Annotations.cs index 6f5abfa..1630ada 100644 --- a/src/Annotations.cs +++ b/src/Annotations.cs @@ -1865,5 +1865,32 @@ public TestSubjectAttribute([NotNull] Type subject) } } + /// + /// Signifies a generic argument as the test subject for a test class. + /// + /// + /// The 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. + /// + /// + /// public class BaseTestClass<[MeansTestSubject] T> + /// { + /// protected T Component { get; } + /// } + /// + /// public class CalculatorAdditionTests : BaseTestClass<Calculator> + /// { + /// [Test] + /// public void Should_add_two_numbers() + /// { + /// Assert.That(Component.Add(2,3 ), Is.EqualTo(5)); + /// } + /// } + /// + [AttributeUsage(AttributeTargets.GenericParameter)] + [Conditional("JETBRAINS_ANNOTATIONS")] + public sealed class MeansTestSubjectAttribute : Attribute { } + #endregion }