ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: NUnit. Incompatible argument type or incorrect argument value.

Last modified: 11 February 2024

This inspection notifies you about mismatch of the type of a value that you pass to your test via the TestCase argument and the type of the corresponding parameter in the test method. For example, in the test method below the error is quite obvious:

But sometimes, the error can be harder to spot. For example

In this case, the array will not be created automatically, so the argument must be an array for the test to work correctly:

Note that NUnit will try to convert the value supplied via TestCase before using it in the test, and ReSharper takes this conversion into consideration before issuing the warning. Note also that NUnit 2.x and NUnit 3 have different value conversion logic.