Search in sources :

Example 11 with BlockJUnit4ClassRunner

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

the class ParentRunnerClassLoaderTest method testBackwardCompatibilityWithOverrideGetName.

@Test
public void testBackwardCompatibilityWithOverrideGetName() throws Exception {
    final Class<TestWithClassRule> originalTestClass = TestWithClassRule.class;
    final Class<?> waitClass = ParentRunnerClassLoaderTest.class;
    ParentRunner<FrameworkMethod> subParentRunner = new BlockJUnit4ClassRunner(originalTestClass) {

        @Override
        protected String getName() {
            return waitClass.getName();
        }
    };
    Description description = subParentRunner.getDescription();
    Class<?> result = description.getTestClass();
    assertEquals("Subclass of ParentRunner can override getName method and specify another test class for run, " + "we should  maintain backwards compatibility with JUnit 4.12", waitClass, result);
}
Also used : Description(org.junit.runner.Description) BlockJUnit4ClassRunner(org.junit.runners.BlockJUnit4ClassRunner) FrameworkMethod(org.junit.runners.model.FrameworkMethod) Test(org.junit.Test)

Example 12 with BlockJUnit4ClassRunner

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

the class ParentRunnerClassLoaderTest method runTestWithParentRunner.

private void runTestWithParentRunner(Class<?> testClass) throws InitializationError {
    ParentRunner<?> runner = new BlockJUnit4ClassRunner(testClass);
    runner.run(new RunNotifier());
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) BlockJUnit4ClassRunner(org.junit.runners.BlockJUnit4ClassRunner)

Example 13 with BlockJUnit4ClassRunner

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

the class ParentRunnerTest method useChildHarvester.

@Test
public void useChildHarvester() throws InitializationError {
    log = "";
    ParentRunner<?> runner = new BlockJUnit4ClassRunner(FruitTest.class);
    runner.setScheduler(new RunnerScheduler() {

        public void schedule(Runnable childStatement) {
            log += "before ";
            childStatement.run();
            log += "after ";
        }

        public void finished() {
            log += "afterAll ";
        }
    });
    runner.run(new RunNotifier());
    assertEquals("before apple after before banana after afterAll ", log);
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) BlockJUnit4ClassRunner(org.junit.runners.BlockJUnit4ClassRunner) RunnerScheduler(org.junit.runners.model.RunnerScheduler) Test(org.junit.Test)

Example 14 with BlockJUnit4ClassRunner

use of org.junit.runners.BlockJUnit4ClassRunner in project vert.x by eclipse.

the class AsyncTestBaseTest method testReportLateFailures.

@Test
public void testReportLateFailures() {
    Result result;
    try {
        result = new JUnitCore().run(new BlockJUnit4ClassRunner(LateFailureReport.class));
    } catch (InitializationError initializationError) {
        throw new AssertionError(initializationError);
    }
    assertEquals(1, result.getFailureCount());
    assertEquals(IllegalStateException.class, result.getFailures().get(0).getException().getClass());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) BlockJUnit4ClassRunner(org.junit.runners.BlockJUnit4ClassRunner) InitializationError(org.junit.runners.model.InitializationError) Result(org.junit.runner.Result) Test(org.junit.Test)

Aggregations

BlockJUnit4ClassRunner (org.junit.runners.BlockJUnit4ClassRunner)14 Test (org.junit.Test)8 Description (org.junit.runner.Description)4 RunNotifier (org.junit.runner.notification.RunNotifier)4 CategoryFilter (org.junit.experimental.categories.Categories.CategoryFilter)3 Field (java.lang.reflect.Field)2 Test (org.junit.jupiter.api.Test)2 UniqueId (org.junit.platform.engine.UniqueId)2 Description.createTestDescription (org.junit.runner.Description.createTestDescription)2 InitializationError (org.junit.runners.model.InitializationError)2 RunnerTestDescriptor (org.junit.vintage.engine.descriptor.RunnerTestDescriptor)2 VintageTestDescriptor (org.junit.vintage.engine.descriptor.VintageTestDescriptor)2 PlainJUnit4TestCaseWithSingleTestWhichFails (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails)2 TestClassLoader (com.alipay.sofa.ark.container.test.TestClassLoader)1 ArkEvent (com.alipay.sofa.ark.spi.event.ArkEvent)1 ArkBootRunner (com.alipay.sofa.ark.springboot.runner.ArkBootRunner)1 File (java.io.File)1 EclipseCompiler (org.eclipse.jdt.internal.compiler.tool.EclipseCompiler)1 CaptureLog (org.evosuite.testcarver.capture.CaptureLog)1 JUnitCore (org.junit.runner.JUnitCore)1