Skip to content

Gendarme.Rules.NUnit.ProvideMessageOnAssertCallsRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

ProvideMessageOnAssertCallsRule

Assembly: Gendarme.Rules.NUnit
Version: git

Description

This rule checks that all Assert.* methods are calling with 'message' parameter, which helps to easily identify failing test.

Examples

Bad example:

[Test]
public void TestThings ()
{
    Assert.AreEqual(10, 20);
    Assert.AreEqual(30, 40);
}

Good example:

[Test]
public void TestThings ()
{
    Assert.AreEqual(10, 20, "10 equal to 20 test");
    Assert.AreEqual(30, 40, "30 equal to 40 test");
    

Notes

  • This rule will not report any problems if only one Assert.* call was made inside a method, because it's easy to identify failing test in this case.

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally