Reputation: 760
I would like to ignore a test based on the input given to the test , I searched around and found couple of solutions,They are as follows
Assert.Ignore();
Assert.Inconclusive();
But what i need is it should ignore only when i passed the true value something like
Assert.Ignore(true);
I did achieve what i wanted using the conditional statement like the following
if(ignoreTheTest)
{
Assert.Ignore();
}
i feel some what this is not best way of doing this , i want to know if there was a better way doing it.Thank you in advance :).I am just starting out ,sorry with the novice que
Upvotes: 1
Views: 271
Reputation: 7301
I have never used this, but if your complaint is about the if-statement that you have to write every time I would suggest you to extract the code into a method::
public static void Assert(Func<bool> cond, string message = "")
{
if(cond())
{
Assert.Ignore(message);
}
}
Upvotes: 1