Search in sources :

Example 26 with JUnitCore

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

the class AnnotationTest method testRunAllAfterClasses.

public void testRunAllAfterClasses() {
    log = "";
    JUnitCore core = new JUnitCore();
    core.run(RunAllAfterClasses.class);
    assertTrue(log.contains("one"));
    assertTrue(log.contains("two"));
}
Also used : JUnitCore(org.junit.runner.JUnitCore)

Example 27 with JUnitCore

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

the class AnnotationTest method testRunFailure.

public void testRunFailure() throws Exception {
    JUnitCore runner = new JUnitCore();
    Result result = runner.run(FailureTest.class);
    assertEquals(1, result.getRunCount());
    assertEquals(1, result.getFailureCount());
    assertEquals(AssertionError.class, result.getFailures().get(0).getException().getClass());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult)

Example 28 with JUnitCore

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

the class AnnotationTest method testTestInheritance.

public void testTestInheritance() throws Exception {
    log = "";
    JUnitCore core = new JUnitCore();
    core.run(SubTest.class);
    // The order in which the test methods are called is unspecified
    assertTrue(log.contains("Sub"));
    assertTrue(log.contains("Two"));
    assertFalse(log.contains("Super"));
}
Also used : JUnitCore(org.junit.runner.JUnitCore)

Example 29 with JUnitCore

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

the class AssumptionTest method runAndGetAssumptionFailures.

/**
     * Helper method that runs tests on <code>clazz</code> and returns any
     * {@link Failure} objects that were {@link AssumptionViolatedException}s.
     */
private static List<Failure> runAndGetAssumptionFailures(Class<?> clazz) {
    final List<Failure> failures = new ArrayList<Failure>();
    final JUnitCore core = new JUnitCore();
    core.addListener(new RunListener() {

        @Override
        public void testAssumptionFailure(Failure failure) {
            failures.add(failure);
        }
    });
    core.run(clazz);
    return failures;
}
Also used : JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList) Failure(org.junit.runner.notification.Failure) RunListener(org.junit.runner.notification.RunListener)

Example 30 with JUnitCore

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

the class MaxStarterTest method correctErrorFromMalformedTest.

@Test
public void correctErrorFromMalformedTest() {
    Request request = Request.aClass(MalformedJUnit38TestMethod.class);
    JUnitCore core = new JUnitCore();
    Request sorted = fMax.sortRequest(request);
    Runner runner = sorted.getRunner();
    Result result = core.run(runner);
    Failure failure = result.getFailures().get(0);
    assertThat(failure.toString(), containsString("MalformedJUnit38TestMethod"));
    assertThat(failure.toString(), containsString("testNothing"));
    assertThat(failure.toString(), containsString("isn't public"));
}
Also used : JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) Request(org.junit.runner.Request) Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) Test(org.junit.Test)

Aggregations

JUnitCore (org.junit.runner.JUnitCore)169 Result (org.junit.runner.Result)100 Test (org.junit.Test)88 Request (org.junit.runner.Request)32 PrintableResult.testResult (org.junit.experimental.results.PrintableResult.testResult)22 Failure (org.junit.runner.notification.Failure)21 Description (org.junit.runner.Description)16 RunListener (org.junit.runner.notification.RunListener)16 TestResult (junit.framework.TestResult)14 ArrayList (java.util.ArrayList)13 TextListener (org.junit.internal.TextListener)12 Runner (org.junit.runner.Runner)9 RandomizedRunner (com.carrotsearch.randomizedtesting.RandomizedRunner)7 TestSuiteModel (com.google.testing.junit.runner.model.TestSuiteModel)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 OutputStream (java.io.OutputStream)5 CategoryFilter (org.junit.experimental.categories.Categories.CategoryFilter)5 File (java.io.File)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 InOrder (org.mockito.InOrder)4