views:

52

answers:

1

I'm sitting with a legacy project, and we're starting to replace some old legacycode. As Rmock don't have support for junit4, we would like to replace it. One thing i was wondering is - how could i replace the dynamictestsuite feature of rmock. This is a good feature where you create a dynamic testsuite for each run, and can do stuff like.

@Override
protected void setupSuite() {
        forEach(is.clazz.assignableTo(TestCase.class).and(is.not(is.clazz.name(is.endingWith("oldTest")))).perform(addAllToSuite);

}

that would get all testclasses not ending with oldTest and create a dynamictestsuite. And so on, you get the point.

+1  A: 

ClasspathSuite can define a suite by searching for JUnit test classes in the class path, with a filter on the test class names to include or exclude.

import org.junit.extensions.cpsuite.ClasspathSuite.*;
import org.junit.runner.RunWith;

@RunWith(ClasspathSuite.class)
@ClassnameFilters({"!.*oldTest"})
public class MySuite {}
Jim Huang