ReSharper 2024.3 Help

Code inspection: NUnit. Implicitly unspecified null values.

This inspection reports implicit values passed to NUnit tests annotated with the [Sequential] attribute.

When you use the [Sequential] attribute on a test where multiple parameters are annotated with the [Values] attribute, the number of generated test cases will correspond to the [Values] attribute with the maximum number of arguments. For attributes with fewer arguments, NUnit will implicitly use null for reference types or the default values for value types.

For example, for the following test

[Test, Sequential] public void MyTest( [Values(1, 2, 3)] int num, [Values("A", "B")] string str) { // do something }

NUnit will generate 3 test cases because the first [Values] attribute is used with 3 arguments, but in the third case it will use null because the second attribute is used with only 2 arguments:

MyTest(1, "A"); MyTest(2, "B"); MyTest(3, null);

Although this is allowed by the NUnit specification, implicit values may lead to unexpected test results. To avoid this, it is recommended that all [Values] attributes in the test have the same number of arguments.

Last modified: 11 February 2024