DanielV
DanielV

Reputation: 2700

Unit test ignore and provide explanation about it

Is it possible to provide an explicative message in the Ignore decorator to a unit test in C#, like this?

[TestMethod]
[Ignore("This is intended to work locally only because lack of permissions")]
public void TestStartAcquireIfEmpty()
{

}

So that in case a future development is done, this decorator can be removed from the unit test

Upvotes: 2

Views: 4299

Answers (2)

Guru Stron
Guru Stron

Reputation: 143243

Three of the most popular .NET test frameworks allow to mark test as ignored and provide ignore reason:

  • MsTest's IgnoreAttribute has constructor accepting message parameter
  • Similarly NUnit's IgnoreAttribute has constructor accepting reason parameter
  • XUnit requires to fill Skip property (which is of string type) to ignore test

Upvotes: 2

vc 74
vc 74

Reputation: 38179

You could add this line as the first line of your test:

Assert.Inconclusive("This is intended to work locally only because lack of permissions");

The test result will be shown as inconclusive with this message.

Upvotes: 2

Related Questions