Reputation: 4728
With respect to NUnit: is there a mechanism to conditionally ignore a specific test case?
Something along the lines of:
[TestCase(1,2)]
[TestCase(3,4, Ignore=true, IgnoreReason="Doesn't meet conditionA", Condition=IsConditionA())]
public voidTestA(int a, int b)
Is there any such mechanism or is the only way creating separate test cases and calling Assert.Ignore()
in the test body?
Upvotes: 9
Views: 8517
Reputation: 64
I think it helps test readability to minimize the conditional logic inside the test body. But you can definitely generate the tests cases dynamically using the testcasesource attribute on the test and in a separate method dynamically generate a list of test cases to run using the nunit testcasedata object.
So only the tests that you need to/ are valid to execute are run but you still have a chance to log etc the cases.
http://www.nunit.org/index.php?p=testCaseSource&r=2.6.4
Upvotes: 0
Reputation: 397
You could add the following to the body of the test:
if (a==3 && b == 4 && !IsConditionA()) { Assert.Ignore() }
This you would have to do for every testcase you would want to ignore. You would not replicate the testbody in this case, but you would add to it for every ignored testcase.
Upvotes: 13