Description
When the list of arguments to the Arguments attribute is empty, and the test has a params parameter, the test is invoked with null rather than an empty array.
Consider the following example:
[Test]
[Arguments] // this one will fail, following ones will pass
[Arguments("a")]
[Arguments("a", "B")]
[Arguments("a", "b", "c")]
public async Task SomeTest(params string[] args)
{
// do some test using the "args" array
// if no arguments are provided, expect it to be empty, not null
await Assert.That(args).IsNotNull();
}
Expected Behavior
Expected the test to be invoked with an empty array - the standard C# behavior when a method with a params argument is invoked with no arguments.
Actual Behavior
The test's params argument is null
Steps to Reproduce
Run the following test. It should never fail, but it does.
[Test]
[Arguments]
[Arguments("a")]
[Arguments("a", "B")]
[Arguments("a", "b", "c")]
public async Task SomeTest(params string[] args)
{
// do some test using the "args" array
// if no arguments are provided, expect it to be empty, not null
await Assert.That(args).IsNotNull();
}
TUnit Version
1.12.15
.NET Version
.NET 9.0
Operating System
Windows
IDE / Test Runner
JetBrains Rider
Error Output / Stack Trace
Additional Context
No AOT / trimming.
IDE-Specific Issue?
Description
When the list of arguments to the
Argumentsattribute is empty, and the test has aparamsparameter, the test is invoked withnullrather than an empty array.Consider the following example:
Expected Behavior
Expected the test to be invoked with an empty array - the standard C# behavior when a method with a
paramsargument is invoked with no arguments.Actual Behavior
The test's
paramsargument isnullSteps to Reproduce
Run the following test. It should never fail, but it does.
TUnit Version
1.12.15
.NET Version
.NET 9.0
Operating System
Windows
IDE / Test Runner
JetBrains Rider
Error Output / Stack Trace
Additional Context
No AOT / trimming.
IDE-Specific Issue?
dotnet testordotnet run, not just in my IDE