Search in sources :

Example 71 with Result

use of org.junit.runner.Result 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 72 with Result

use of org.junit.runner.Result in project junit4 by junit-team.

the class SuiteMethodTest method suiteIsUsedWithJUnit4Classes.

@Test
public void suiteIsUsedWithJUnit4Classes() {
    wasRun = false;
    Result result = JUnitCore.runClasses(NewTestSuiteFails.class);
    assertEquals(1, result.getFailureCount());
    assertFalse(wasRun);
}
Also used : Result(org.junit.runner.Result) Test(org.junit.Test)

Example 73 with Result

use of org.junit.runner.Result in project junit4 by junit-team.

the class SuiteMethodTest method makeSureSuiteNotUsedWithJUnit4Classes2.

@Test
public void makeSureSuiteNotUsedWithJUnit4Classes2() {
    wasRun = false;
    NewTestSuiteNotUsed.wasIgnoredRun = false;
    Result res = JUnitCore.runClasses(NewTestSuiteNotUsed.class);
    assertTrue(wasRun);
    assertFalse(NewTestSuiteNotUsed.wasIgnoredRun);
    assertEquals(0, res.getFailureCount());
    assertEquals(1, res.getRunCount());
    assertEquals(0, res.getIgnoreCount());
}
Also used : Result(org.junit.runner.Result) Test(org.junit.Test)

Example 74 with Result

use of org.junit.runner.Result 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 75 with Result

use of org.junit.runner.Result in project junit4 by junit-team.

the class JUnit38ClassRunnerTest method testListener.

@Test
public void testListener() throws Exception {
    JUnitCore runner = new JUnitCore();
    RunListener listener = new RunListener() {

        @Override
        public void testStarted(Description description) {
            assertEquals(Description.createTestDescription(OneTest.class, "testOne"), description);
            count++;
        }
    };
    runner.addListener(listener);
    count = 0;
    Result result = runner.run(OneTest.class);
    assertEquals(1, count);
    assertEquals(1, result.getRunCount());
}
Also used : Description(org.junit.runner.Description) JUnitCore(org.junit.runner.JUnitCore) RunListener(org.junit.runner.notification.RunListener) Result(org.junit.runner.Result) Test(org.junit.Test)

Aggregations

Result (org.junit.runner.Result)343 Test (org.junit.Test)267 JUnitCore (org.junit.runner.JUnitCore)104 Failure (org.junit.runner.notification.Failure)93 PrintableResult.testResult (org.junit.experimental.results.PrintableResult.testResult)61 UnitTest (org.apache.geode.test.junit.categories.UnitTest)56 Description (org.junit.runner.Description)28 Request (org.junit.runner.Request)23 TestResult (junit.framework.TestResult)21 RunListener (org.junit.runner.notification.RunListener)18 IOException (java.io.IOException)12 SettableCurrentRunningTest (com.google.testing.junit.runner.internal.junit4.SettableCurrentRunningTest)11 CurrentRunningTest (com.google.testing.junit.runner.util.CurrentRunningTest)11 JUnit4TestListener (com.intellij.junit4.JUnit4TestListener)9 ArrayList (java.util.ArrayList)8 Runner (org.junit.runner.Runner)7 ComparisonFailure (org.junit.ComparisonFailure)6 CategoryFilter (org.junit.experimental.categories.Categories.CategoryFilter)5 TextListener (org.junit.internal.TextListener)5 ShardingEnvironment (com.google.testing.junit.runner.sharding.ShardingEnvironment)4