Search in sources :

Example 41 with JUnitCore

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

the class ClassLevelMethodsWithIgnoredTestsTest method beforeClassShouldNotRunWhenAllTestsAreFiltered.

@Test
public void beforeClassShouldNotRunWhenAllTestsAreFiltered() {
    Result result = new JUnitCore().run(Request.classes(BeforeClassWithFilteredTest.class, HasUnfilteredTest.class).filterWith(CategoryFilter.exclude(FilteredTests.class)));
    analyseResult(result, "BeforeClass should not have been executed because the test method is filtered!");
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 42 with JUnitCore

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

the class AnnotationTest method testOldTest.

public void testOldTest() throws Exception {
    JUnitCore runner = new JUnitCore();
    runner.run(OldTest.class);
    assertTrue(run);
}
Also used : JUnitCore(org.junit.runner.JUnitCore)

Example 43 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 44 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 45 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)

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