ReSharper 2024.1 Help

Code inspection: NUnit. Missing expected result for non-void test method.

Category

NUnit

ID

NUnit.TestCaseAttributeRequiresExpectedResult

EditorConfig

resharper_n_unit_test_case_attribute_requires_expected_result_highlighting

Default severity

Warning

Language

C#

Requires SWA

No

This inspection draws your attention to the fact that the expected result is missing in the Test or TestCase attribute for a test method with a return value. ReSharper also suggests a quick-fix that adds the ExpectedResult argument with the default value of the compatible type, which you can then replace with a desired value.

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