diff --git a/TUnit.Core/Attributes/TestData/ArgumentsAttribute.cs b/TUnit.Core/Attributes/TestData/ArgumentsAttribute.cs index 974ebd8232..8ad3d88d69 100644 --- a/TUnit.Core/Attributes/TestData/ArgumentsAttribute.cs +++ b/TUnit.Core/Attributes/TestData/ArgumentsAttribute.cs @@ -62,10 +62,14 @@ public sealed class ArgumentsAttribute : Attribute, IDataSourceAttribute, ITestR public ArgumentsAttribute(params object?[]? values) { - if (values == null || values.Length == 0) + if (values == null) { Values = [null]; } + else if (values.Length == 0) + { + Values = []; + } else { Values = values; diff --git a/TUnit.TestProject/ParamsArgumentsTests.cs b/TUnit.TestProject/ParamsArgumentsTests.cs index 78ad3eb7fe..d13feaf495 100644 --- a/TUnit.TestProject/ParamsArgumentsTests.cs +++ b/TUnit.TestProject/ParamsArgumentsTests.cs @@ -44,6 +44,17 @@ public async Task EmptyParamsArray(string name, params Type[] types) await Assert.That(types.Length).IsEqualTo(0); } + [Test] + [Arguments] + [Arguments("a")] + [Arguments("a", "b")] + [Arguments("a", "b", "c")] + public async Task ParamsOnlyWithEmptyArguments(params string[] args) + { + // When [Arguments] has no values, params should be an empty array, not null + await Assert.That(args).IsNotNull(); + } + [Test] [Arguments(1, "single")] public async Task SingleStringInParamsArray(int id, params string[] values)