I want to run Junit test suites that contain various test classes.
Of all tests, i want to exclude test methods annotated with a certain annotation.
I am aware of the @Ignore annotation but i do not want to use it here because i want to be able to ignore different test methods if i call the tests from different test suites.
I have tried it and it does not work. Running my suite without @ExcludeCategory(IgnoreMeForSpecialReason.class) runs the same amount of test cases as are run with @ExcludeCategory(IgnoreMeForSpecialReason.class)
To illustrate it:
This suite
//version 1
@RunWith(Categories.class)
@ExcludeCategory(IgnoreForSpecialReasonA.class)
@SuiteClasses({
// add your test classes here
Module1Test.class,
Module2Test.class,
Module3Test.class
})
public class MySuiteA
{
}
runs the same amount of tests as does this version of the suite:
//version 2
@RunWith(Categories.class)
//@ExcludeCategory(IgnoreForSpecialReasonA.class)
@SuiteClasses({
// add your test classes here
Module1Test.class,
Module2Test.class,
Module3Test.class
})
public class MySuiteA
{
}
One test method of Module1Test is annotated with the @IgnoreForSpecialReasonA Annotation. That method should be skipped in version1 of my example, but it is run.
How can i achieve that @ExcludeCategory actually works with suites?
Cheers!
@ExcludeCategory
should work with @Category
.
Make sure your ignore methods/classes are annotated with @Category(IgnoreForSpecialReasonA.class)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With