ReSharper 2024.1 Help

Code Inspection: NUnit. Redundant argument instead of ExpectedResult

Category

NUnit

ID

NUnit.RedundantArgumentInsteadOfExpectedResult

EditorConfig

resharper_n_unit_redundant_argument_instead_of_expected_result_highlighting

Default severity

Warning

Language

C#

Requires SWA

No

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: 15 April 2024