Search in sources :

Example 1 with JUnit38ClassRunner

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

the class OldTestClassAdaptingListenerTest method addFailureDelegatesToNotifier.

@Test
public void addFailureDelegatesToNotifier() {
    Result result = new Result();
    RunListener listener = result.createListener();
    RunNotifier notifier = new RunNotifier();
    notifier.addFirstListener(listener);
    TestCase testCase = new TestCase() {
    };
    TestListener adaptingListener = new JUnit38ClassRunner(testCase).createAdaptingListener(notifier);
    adaptingListener.addFailure(testCase, new AssertionFailedError());
    assertEquals(1, result.getFailureCount());
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) TestCase(junit.framework.TestCase) JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) TestListener(junit.framework.TestListener) AssertionFailedError(junit.framework.AssertionFailedError) Result(org.junit.runner.Result) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 2 with JUnit38ClassRunner

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

the class JUnit38ClassRunnerTest method canUnadaptAnAdapter.

@Test
public void canUnadaptAnAdapter() {
    JUnit38ClassRunner runner = new JUnit38ClassRunner(new JUnit4TestAdapter(AnnotatedTest.class));
    Result result = new JUnitCore().run(runner);
    Failure failure = result.getFailures().get(0);
    assertEquals(Description.createTestDescription(AnnotatedTest.class, "foo"), failure.getDescription());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter) Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 3 with JUnit38ClassRunner

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

the class JUnit38ClassRunnerTest method plansDecoratorCorrectly.

@Test
public void plansDecoratorCorrectly() {
    JUnit38ClassRunner runner = new JUnit38ClassRunner(new TestDecorator(new TestSuite(MyTest.class)));
    assertEquals(1, runner.testCount());
}
Also used : TestSuite(junit.framework.TestSuite) JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) TestDecorator(junit.extensions.TestDecorator) Test(org.junit.Test)

Example 4 with JUnit38ClassRunner

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

the class MaxCore method buildRunner.

private Runner buildRunner(Description each) {
    if (each.toString().equals("TestSuite with 0 tests")) {
        return Suite.emptySuite();
    }
    if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
        // thrown away which method the warning is for.
        return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
    }
    Class<?> type = each.getTestClass();
    if (type == null) {
        throw new RuntimeException("Can't build a runner from description [" + each + "]");
    }
    String methodName = each.getMethodName();
    if (methodName == null) {
        return Request.aClass(type).getRunner();
    }
    return Request.method(type, methodName).getRunner();
}
Also used : TestSuite(junit.framework.TestSuite) JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner)

Example 5 with JUnit38ClassRunner

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

the class JUnit38ClassRunnerTest method filterNoTestsRemain.

/**
     * Test that NoTestsRemainException is thrown when all methods have been filtered.
     */
@Test(expected = NoTestsRemainException.class)
public void filterNoTestsRemain() throws NoTestsRemainException {
    JUnit38ClassRunner runner = new JUnit38ClassRunner(OneTest.class);
    runner.filter(new RejectAllTestsFilter());
}
Also used : JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) Test(org.junit.Test)

Aggregations

JUnit38ClassRunner (org.junit.internal.runners.JUnit38ClassRunner)9 Test (org.junit.Test)7 TestSuite (junit.framework.TestSuite)2 Result (org.junit.runner.Result)2 TestDecorator (junit.extensions.TestDecorator)1 AssertionFailedError (junit.framework.AssertionFailedError)1 JUnit4TestAdapter (junit.framework.JUnit4TestAdapter)1 TestCase (junit.framework.TestCase)1 TestListener (junit.framework.TestListener)1 Description (org.junit.runner.Description)1 JUnitCore (org.junit.runner.JUnitCore)1 Filter (org.junit.runner.manipulation.Filter)1 Failure (org.junit.runner.notification.Failure)1 RunListener (org.junit.runner.notification.RunListener)1 RunNotifier (org.junit.runner.notification.RunNotifier)1