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
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:
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.