Search code examples
javaunit-testingjunit

is there any conditional annotation in JUnit to mark few test cases to be skipped?


As far as I know to skip a test case the simplest thing to do is to remove the @Test annotation, but to do it over a large number of test cases is cumbersome. I was wondering if there is any annotation available in JUnit to turn off few test cases conditionally.


Solution

  • Hard to know if it is the @Ignore annotation that you are looking for, or if you actually want to turn off certain JUnit tests conditionally. Turning off testcases conditionally is done using Assume.

    You can read about assumptions in the release notes for junit 4.5

    There's also a rather good thread here on stack over flow: Conditionally ignoring tests in JUnit 4