I am currently using JUnit 4 and have a need to divide my tests into groups that can be run selectively in any combination. I know TestNG has a feature to annotate tests to assi
Check out Spring's SpringJUnit4ClassRunner. I've used it to optionally run tests based on a System property, using the IfProfileValue annotation.
This:
@IfProfileValue(name="test-groups", values={"unit-tests", "integration-tests"})
public void testWhichRunsForUnitOrIntegrationTestGroups() {
// ...
}
Will run if the System property 'test-groups' is set to either 'unit-tests' or 'integration-tests'.
Update: JUnitExt has @Category
and @Prerequisite
annotations and looks like it should do what you need. However, I've never used it myself, so I can't vouch for it.