Search in sources :

Example 56 with JUnitCore

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

the class TimeoutTest method failureWithTimeout.

@Test
public void failureWithTimeout() throws Exception {
    JUnitCore core = new JUnitCore();
    Result result = core.run(FailureWithTimeoutTest.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) TestResult(junit.framework.TestResult) Test(org.junit.Test)

Example 57 with JUnitCore

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

the class TimeoutTest method timeoutFailure.

@Ignore("was breaking gump")
@Test
public void timeoutFailure() throws Exception {
    JUnitCore core = new JUnitCore();
    Result result = core.run(TimeoutFailureTest.class);
    assertEquals(1, result.getRunCount());
    assertEquals(1, result.getFailureCount());
    assertEquals(InterruptedException.class, result.getFailures().get(0).getException().getClass());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) TestResult(junit.framework.TestResult) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 58 with JUnitCore

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

the class TimeoutTest method stalledThreadAppearsInStackTrace.

@Test
public void stalledThreadAppearsInStackTrace() throws Exception {
    JUnitCore core = new JUnitCore();
    Result result = core.run(InfiniteLoopTest.class);
    assertEquals(1, result.getRunCount());
    assertEquals(1, result.getFailureCount());
    Throwable exception = result.getFailures().get(0).getException();
    // Make sure we have the stalled frame on the stack somewhere
    assertThat(stackForException(exception), containsString("infiniteLoop"));
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) TestResult(junit.framework.TestResult) Test(org.junit.Test)

Example 59 with JUnitCore

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

the class TimeoutTest method timeoutFailureMultithreaded.

@Test
public void timeoutFailureMultithreaded() throws Exception {
    JUnitCore core = new JUnitCore();
    Result result = core.run(InfiniteLoopWithStuckThreadTest.class);
    assertEquals(1, result.getRunCount());
    assertEquals(2, result.getFailureCount());
    Throwable[] exception = new Throwable[2];
    for (int i = 0; i < 2; i++) exception[i] = result.getFailures().get(i).getException();
    assertThat(exception[0].getMessage(), containsString("test timed out after 100 milliseconds"));
    assertThat(stackForException(exception[0]), containsString("Thread.join"));
    assertThat(exception[1].getMessage(), containsString("Appears to be stuck in thread timeout-thr2"));
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) TestResult(junit.framework.TestResult) Test(org.junit.Test)

Example 60 with JUnitCore

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

the class AnnotationTest method testOldSuiteTest.

public void testOldSuiteTest() throws Exception {
    TestSuite suite = new TestSuite(OldSuiteTest.class);
    JUnitCore runner = new JUnitCore();
    runner.run(suite);
    assertTrue(run);
}
Also used : TestSuite(junit.framework.TestSuite) 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