DrunkCoder DrunkCoder - 6 months ago 36
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?


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!