Search in sources :

Example 31 with JUnitCore

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

the class SuiteTest method suiteClassDoesNotNeedToBePublic.

@Test
public void suiteClassDoesNotNeedToBePublic() {
    JUnitCore core = new JUnitCore();
    Result result = core.run(NonPublicSuite.class);
    assertEquals(1, result.getRunCount());
    assertEquals(0, result.getFailureCount());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) TestResult(junit.framework.TestResult) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult) Test(org.junit.Test)

Example 32 with JUnitCore

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

the class UseSuiteAsASuperclassTest method ensureTestsAreRun.

@Test
public void ensureTestsAreRun() {
    JUnitCore core = new JUnitCore();
    Result result = core.run(AllWithMySuite.class);
    assertEquals(2, result.getRunCount());
    assertEquals(1, result.getFailureCount());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 33 with JUnitCore

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

the class ParentRunnerFilteringTest method testCountClassFiltering.

@Test
public void testCountClassFiltering() throws Exception {
    JUnitCore junitCore = new JUnitCore();
    Request request = Request.aClass(ExampleTest.class);
    CountingFilter countingFilter = new CountingFilter();
    Request requestFiltered = request.filterWith(countingFilter);
    Result result = junitCore.run(requestFiltered);
    assertEquals(1, result.getRunCount());
    assertEquals(0, result.getFailureCount());
    Description desc = createTestDescription(ExampleTest.class, "test1");
    assertEquals(1, countingFilter.getCount(desc));
}
Also used : Description.createTestDescription(org.junit.runner.Description.createTestDescription) Description(org.junit.runner.Description) Description.createSuiteDescription(org.junit.runner.Description.createSuiteDescription) JUnitCore(org.junit.runner.JUnitCore) Request(org.junit.runner.Request) Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult) Test(org.junit.Test)

Example 34 with JUnitCore

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

the class ListenerTest method notifyListenersInTheOrderInWhichTheyAreAdded.

@Test
public void notifyListenersInTheOrderInWhichTheyAreAdded() {
    JUnitCore core = new JUnitCore();
    log = "";
    core.addListener(new RunListener() {

        @Override
        public void testRunStarted(Description description) throws Exception {
            log += "first ";
        }
    });
    core.addListener(new RunListener() {

        @Override
        public void testRunStarted(Description description) throws Exception {
            log += "second ";
        }
    });
    core.run(OneTest.class);
    assertEquals("first second ", log);
}
Also used : Description(org.junit.runner.Description) JUnitCore(org.junit.runner.JUnitCore) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 35 with JUnitCore

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

the class RunnerTest method testFinished.

@Test
public void testFinished() {
    JUnitCore runner = new JUnitCore();
    wasRun = false;
    RunListener listener = new MyListener() {

        @Override
        public void testFinished(Description description) {
            wasRun = true;
        }
    };
    runner.addListener(listener);
    runner.run(NewExample.class);
    assertTrue(wasRun);
}
Also used : Description(org.junit.runner.Description) JUnitCore(org.junit.runner.JUnitCore) RunListener(org.junit.runner.notification.RunListener) 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