Want to run all tests belonging to a certain Category in JUnit 4 I found out one possible way to achieve what I want, but I don’t consider this to be the best possible solution as it relies on ClassPathSuite library that is not part of JUnit.
I define the test suite for slow tests like this:
1 2 3 4 5 | @RunWith(Categories.class) @Categories.IncludeCategory(SlowTests.class) @Suite.SuiteClasses( { AllTests.class }) public class SlowTestSuite { } |
AllTests class is defined like this:
@RunWith(ClasspathSuite.class)
public class AllTests {
}
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.