Search in sources :

Example 41 with InitializationError

use of org.junit.runners.model.InitializationError in project junit4 by junit-team.

the class Request method classes.

/**
 * Create a <code>Request</code> that, when processed, will run all the tests
 * in a set of classes.
 *
 * @param computer Helps construct Runners from classes
 * @param classes the classes containing the tests
 * @return a <code>Request</code> that will cause all tests in the classes to be run
 */
public static Request classes(Computer computer, Class<?>... classes) {
    try {
        AllDefaultPossibilitiesBuilder builder = new AllDefaultPossibilitiesBuilder();
        Runner suite = computer.getSuite(builder, classes);
        return runner(suite);
    } catch (InitializationError e) {
        return runner(new ErrorReportingRunner(e, classes));
    }
}
Also used : ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner) AllDefaultPossibilitiesBuilder(org.junit.internal.builders.AllDefaultPossibilitiesBuilder) InitializationError(org.junit.runners.model.InitializationError) ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner)

Example 42 with InitializationError

use of org.junit.runners.model.InitializationError in project sofa-ark by alipay.

the class ArkJUnit4RunnerTest method testJUnitRunner.

@Test
public void testJUnitRunner() {
    try {
        Assert.assertTrue("@Before".equals(state));
        state = "@Test";
        ArkJUnit4Runner runner = new ArkJUnit4Runner(ArkJUnit4RunnerTest.class);
        ClassLoader loader = runner.getTestClass().getJavaClass().getClassLoader();
        Assert.assertTrue(loader.getClass().getCanonicalName().equals(TestClassLoader.class.getCanonicalName()));
    } catch (InitializationError error) {
        Assert.fail(error.getMessage());
    }
}
Also used : InitializationError(org.junit.runners.model.InitializationError) TestClassLoader(com.alipay.sofa.ark.container.test.TestClassLoader) ContainerClassLoader(com.alipay.sofa.ark.bootstrap.ContainerClassLoader)

Aggregations

InitializationError (org.junit.runners.model.InitializationError)42 ArrayList (java.util.ArrayList)12 IOException (java.io.IOException)9 Runner (org.junit.runner.Runner)7 BlockJUnit4ClassRunner (org.junit.runners.BlockJUnit4ClassRunner)5 Field (java.lang.reflect.Field)4 Method (java.lang.reflect.Method)4 JUnitCore (org.junit.runner.JUnitCore)4 RunNotifier (org.junit.runner.notification.RunNotifier)4 File (java.io.File)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 CucumberScenario (cucumber.runtime.model.CucumberScenario)2 Constructor (java.lang.reflect.Constructor)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 List (java.util.List)2 Test (org.junit.Test)2 AllDefaultPossibilitiesBuilder (org.junit.internal.builders.AllDefaultPossibilitiesBuilder)2 ErrorReportingRunner (org.junit.internal.runners.ErrorReportingRunner)2 ParentRunner (org.junit.runners.ParentRunner)2 FrameworkMethod (org.junit.runners.model.FrameworkMethod)2