Search in sources :

Example 36 with JUnitCore

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

the class TestListenerTest method failingListener.

@Test(expected = Error.class)
public void failingListener() {
    JUnitCore runner = new JUnitCore();
    runner.addListener(new ErrorListener());
    runner.run(OneTest.class);
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Test(org.junit.Test)

Example 37 with JUnitCore

use of org.junit.runner.JUnitCore 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 38 with JUnitCore

use of org.junit.runner.JUnitCore 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)

Example 39 with JUnitCore

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

the class SingleMethodTest method parameterizedFilterToSingleMethod.

@Test
public void parameterizedFilterToSingleMethod() throws Exception {
    count = 0;
    Runner runner = Request.method(ParameterizedOneTimeSetup.class, "one[0]").getRunner();
    Result result = new JUnitCore().run(runner);
    assertEquals(1, result.getRunCount());
}
Also used : Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 40 with JUnitCore

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

the class SingleMethodTest method oneTimeSetup.

@Test
public void oneTimeSetup() throws Exception {
    count = 0;
    Runner runner = Request.method(OneTimeSetup.class, "one").getRunner();
    Result result = new JUnitCore().run(runner);
    assertEquals(1, count);
    assertEquals(1, result.getRunCount());
}
Also used : Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) Test(org.junit.Test)

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