title | description | ms.date | f1_keywords | helpviewer_keywords | author | ms.author | ||||
---|---|---|---|---|---|---|---|---|---|---|
MSTEST0017: Assertion arguments should be passed in the correct order |
Learn about code analysis rule MSTEST0017: Assertion arguments should be passed in the correct order |
03/19/2024 |
|
|
Evangelink |
amauryleve |
Property | Value |
---|---|
Rule ID | MSTEST0017 |
Title | Assertion arguments should be passed in the correct order |
Category | Usage |
Fix is breaking or non-breaking | Non-breaking |
Enabled by default | Yes |
Default severity | Info |
Introduced in version | 3.4.0 |
This rule raises an issue when calls to Assert.AreEqual
, Assert.AreNotEqual
, Assert.AreSame
or Assert.AreNotSame
are following one or multiple of the patterns below:
actual
argument is a constant or literal valueactual
argument variable starts withexpected
,_expected
orExpected
expected
ornotExpected
argument variable starts withactual
actual
is not a local variable
MSTest Assert.AreEqual
, Assert.AreNotEqual
, Assert.AreSame
and Assert.AreNotSame
expect the first argument to be the expected/unexpected value and the second argument to be the actual value.
Having the expected value and the actual value in the wrong order will not alter the outcome of the test (succeeds/fails when it should), but the assertion failure will contain misleading information.
Ensure that that actual
and expected
/notExpected
arguments are passed in the correct order.
Do not suppress a warning from this rule as it would result to misleading output.