ReSharper 2024.3 Help

Code inspection: NUnit. Redundant argument instead of ExpectedResult.

The arguments of NUnit's TestCase attribute can be used for providing both values for test parameters and the expected result of the test. The expected result must be always specified by using the named parameter ExpectedResult.

If the test method returns a value and ReSharper finds an argument with a data value instead of ExpectedResult, it issues a warning and provides a quick-fix that converts the value to the expected result.

[TestCase(100)] // Warning: does the argument mean ExpectedResult? public async Task<int> Test() { // do something return await Task.FromResult(100); }
[TestCase(ExpectedResult = 100)] public async Task<int> Test() { // do something return await Task.FromResult(100); }
Last modified: 08 April 2024