docs/articles/nunit-analyzers/NUnit1029.md
| Topic | Value |
|---|---|
| Id | NUnit1029 |
| Severity | Error |
| Enabled | True |
| Category | Structure |
| Code | TestCaseSourceUsesStringAnalyzer |
The number of parameters provided by the TestCaseSource must match the number of parameters in the Test method.
Note that the current implementation only works for single parameters.
A TestCaseSourceAttribute is used to pass parameters to a test method, but the test method does not expect any or more
parameters than supplied.
private static readonly IEnumerable<string> NUnitNameSpaces = new[] { ".NUnit", ".NUnitExtensions" };
[TestCaseSource(nameof(NUnitNameSpaces))]
public void IsNUnit()
{
}
Match the number of parameters between the test data and the test method.
<!-- start generated config severity -->Configure the severity per project, for more info see MSDN.
# NUnit1029: The number of parameters provided by the TestCaseSource does not match the number of parameters in the Test method
dotnet_diagnostic.NUnit1029.severity = chosenSeverity
where chosenSeverity can be one of none, silent, suggestion, warning, or error.
#pragma warning disable NUnit1029 // The number of parameters provided by the TestCaseSource does not match the number of parameters in the Test method
Code violating the rule here
#pragma warning restore NUnit1029 // The number of parameters provided by the TestCaseSource does not match the number of parameters in the Test method
Or put this at the top of the file to disable all instances.
#pragma warning disable NUnit1029 // The number of parameters provided by the TestCaseSource does not match the number of parameters in the Test method
[SuppressMessage][System.Diagnostics.CodeAnalysis.SuppressMessage("Structure",
"NUnit1029:The number of parameters provided by the TestCaseSource does not match the number of parameters in the Test method",
Justification = "Reason...")]