Search in sources :

Example 46 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 47 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)

Example 48 with JUnitCore

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

the class MaxStarterTest method correctErrorFromHalfMalformedTest.

@Test
public void correctErrorFromHalfMalformedTest() {
    Request request = Request.aClass(HalfMalformedJUnit38TestMethod.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)

Example 49 with JUnitCore

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

the class MaxStarterTest method junit3TestsAreRunOnce.

@Test
public void junit3TestsAreRunOnce() throws Exception {
    Result result = fMax.run(Request.aClass(TwoOldTests.class), new JUnitCore());
    assertEquals(2, result.getRunCount());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 50 with JUnitCore

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

the class StopwatchTest method runTest.

private static Result runTest(Class<?> test) {
    simulateTimePassing(1L);
    JUnitCore junitCore = new JUnitCore();
    return junitCore.run(Request.aClass(test).getRunner());
}
Also used : JUnitCore(org.junit.runner.JUnitCore)

Aggregations

JUnitCore (org.junit.runner.JUnitCore)173 Result (org.junit.runner.Result)104 Test (org.junit.Test)88 Request (org.junit.runner.Request)33 Failure (org.junit.runner.notification.Failure)24 PrintableResult.testResult (org.junit.experimental.results.PrintableResult.testResult)22 RunListener (org.junit.runner.notification.RunListener)17 Description (org.junit.runner.Description)16 ArrayList (java.util.ArrayList)14 TestResult (junit.framework.TestResult)14 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