-
-
Notifications
You must be signed in to change notification settings - Fork 111
Description
Description
I have a "testing library" on top of TUnit that provides a bunch of abstract test classes that users of the library could then extend and use. Naturally, the abstract test classes I define are expected to be subclassed by consuming assemblies, rather than by other classes in the same assembly. This results in the TUnit0059 warning, stating "Abstract test class 'KitSerializationRoundtripTests' has test methods with data sources. Add [InheritsTests] on a concrete class to execute these tests."
But this isn't applicable when there are no actual subclasses in the same assembly to miss [InheritsTests] annotations in the first place. Consider incorporating this understanding into the analyzer.
Minimal repro:
public abstract class SomeTest
{
public static IEnumerable<Type> MessageTypesUnderTest => [];
[Test]
[MethodDataSource(nameof(MessageTypesUnderTest))]
public async Task Test(Type type)
{
}
}Expected Behavior
Described above.
Actual Behavior
Decribed above.
Steps to Reproduce
The minimal repro pasted above.
TUnit Version
1.12.15
.NET Version
.NET 10
Operating System
Linux
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
Additional Context
No response
IDE-Specific Issue?
- I've confirmed this issue occurs when running via
dotnet testordotnet run, not just in my IDE