DrunkCoder DrunkCoder - 1 year ago 127
C# Question

Microsoft unit testing. Is it possible to skip test from test method body?

So I have situation when I need skip current test from test method body.
Simplest way is to write something like this in test method.

if (something) return;

But I have a lot complicated tests and I need a way to skip test from methods which I invoke in current test method body.
Is it possible?

Answer Source

Further to other answers (and as suggested): I'd suggest using Assert.Inconclusive over Assert.Fail, since the original poster's situation is not an explicit failure case.

Using Inconclusive as a result makes it clear that you don't know whether the test succeeded or failed - which is an important distinction. Not proving success doesn't always constitute failure!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download