package junit.framework; import java.util.List; import org.junit.Ignore; import org.junit.runner.Describable; import org.junit.runner.Description; import org.junit.runner.Request; import org.junit.runner.Runner; import org.junit.runner.manipulation.Filter; import org.junit.runner.manipulation.Filterable; import org.junit.runner.manipulation.Orderer; import org.junit.runner.manipulation.InvalidOrderingException; import org.junit.runner.manipulation.NoTestsRemainException; import org.junit.runner.manipulation.Orderable; import org.junit.runner.manipulation.Sorter; /** * The JUnit4TestAdapter enables running JUnit-4-style tests using a JUnit-3-style test runner. * *
To use it, add the following to a test class: *
public static Test suite() { return new JUnit4TestAdapter(YourJUnit4TestClass.class); }*/ public class JUnit4TestAdapter implements Test, Filterable, Orderable, Describable { private final Class> fNewTestClass; private final Runner fRunner; private final JUnit4TestAdapterCache fCache; public JUnit4TestAdapter(Class> newTestClass) { this(newTestClass, JUnit4TestAdapterCache.getDefault()); } public JUnit4TestAdapter(final Class> newTestClass, JUnit4TestAdapterCache cache) { fCache = cache; fNewTestClass = newTestClass; fRunner = Request.classWithoutSuiteMethod(newTestClass).getRunner(); } public int countTestCases() { return fRunner.testCount(); } public void run(TestResult result) { fRunner.run(fCache.getNotifier(result, this)); } // reflective interface for Eclipse public List