JetBrains Rider 2024.1 Help

Code Inspection: NUnit. Mismatch of the range step sign

Category

NUnit

ID

NUnit.RangeStepSignMismatch

EditorConfig

resharper_n_unit_range_step_sign_mismatch_highlighting

Default severity

Warning

Language

C#

Requires SWA

No

The NUnit's Range Attribute allows specifying decreasing ranges of values, that is when from is greater that to.

However, if you explicitly specify the step of the range in the third argument, it must be positive for increasing ranges and negative for decreasing ranges. If the step doesn't match the range, the test will not be executed.

[Test] public void MyTest( // The sign of the 'step' parameter // must be negative to match the range values [Range(20, 10, 2)] int x) { // do something }
Last modified: 15 April 2024