Search in sources :

Example 16 with Result

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

the class StackTracesTest method getTrimmedStackForJUnit4TestFailingInTestRule.

@Test
public void getTrimmedStackForJUnit4TestFailingInTestRule() {
    Result result = runTest(TestWithThrowingTestRule.class);
    assertEquals("Should run the test", 1, result.getRunCount());
    assertEquals("One test should fail", 1, result.getFailureCount());
    Failure failure = result.getFailures().get(0);
    assertHasTrimmedTrace(failure, message("java.lang.RuntimeException: cause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.doThrowExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.throwsExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$ThrowingTestRule.apply"));
    assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());
}
Also used : Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 17 with Result

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

the class StackTracesTest method getTrimmedStackForJUnit4TestFailingInBeforeMethod.

@Test
public void getTrimmedStackForJUnit4TestFailingInBeforeMethod() {
    Result result = runTest(TestWithThrowingBeforeMethod.class);
    assertEquals("Should run the test", 1, result.getRunCount());
    assertEquals("One test should fail", 1, result.getFailureCount());
    Failure failure = result.getFailures().get(0);
    assertHasTrimmedTrace(failure, message("java.lang.RuntimeException: cause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.doThrowExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.throwsExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$TestWithThrowingBeforeMethod.alwaysThrows"));
    assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());
}
Also used : Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 18 with Result

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

the class StackTracesTest method getTrimmedStackForJUnit4TestFailingInTestMethod.

@Test
public void getTrimmedStackForJUnit4TestFailingInTestMethod() {
    Result result = runTest(TestWithOneThrowingTestMethod.class);
    assertEquals("Should run the test", 1, result.getRunCount());
    assertEquals("One test should fail", 1, result.getFailureCount());
    Failure failure = result.getFailures().get(0);
    assertHasTrimmedTrace(failure, message("java.lang.RuntimeException: cause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.doThrowExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$FakeClassUnderTest.throwsExceptionWithoutCause"), at("org.junit.internal.StackTracesTest$TestWithOneThrowingTestMethod.alwaysThrows"));
    assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());
}
Also used : Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 19 with Result

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

the class JavadocTest method slowTests.

@Test
public void slowTests() {
    Result testResult = JUnitCore.runClasses(SlowTestSuite.class);
    assertTrue(testResult.wasSuccessful());
    assertThat("unexpected run count", testResult.getRunCount(), is(2));
    assertThat("unexpected failure count", testResult.getFailureCount(), is(0));
}
Also used : Result(org.junit.runner.Result) Test(org.junit.Test)

Example 20 with Result

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

the class MultiCategoryTest method inheritanceAllIncluded.

@Test
public void inheritanceAllIncluded() {
    Result testResult = JUnitCore.runClasses(InheritanceAll.class);
    assertThat("unexpected run count", testResult.getRunCount(), is(equalTo(1)));
    assertThat("unexpected failure count", testResult.getFailureCount(), is(equalTo(0)));
    assertThat("unexpected failure count", testResult.getIgnoreCount(), is(equalTo(0)));
}
Also used : Result(org.junit.runner.Result) Test(org.junit.Test)

Aggregations

Result (org.junit.runner.Result)337 Test (org.junit.Test)267 JUnitCore (org.junit.runner.JUnitCore)100 Failure (org.junit.runner.notification.Failure)90 PrintableResult.testResult (org.junit.experimental.results.PrintableResult.testResult)61 UnitTest (org.apache.geode.test.junit.categories.UnitTest)56 Description (org.junit.runner.Description)28 Request (org.junit.runner.Request)22 TestResult (junit.framework.TestResult)21 RunListener (org.junit.runner.notification.RunListener)17 IOException (java.io.IOException)12 SettableCurrentRunningTest (com.google.testing.junit.runner.internal.junit4.SettableCurrentRunningTest)11 CurrentRunningTest (com.google.testing.junit.runner.util.CurrentRunningTest)11 JUnit4TestListener (com.intellij.junit4.JUnit4TestListener)9 ArrayList (java.util.ArrayList)7 Runner (org.junit.runner.Runner)7 ComparisonFailure (org.junit.ComparisonFailure)6 CategoryFilter (org.junit.experimental.categories.Categories.CategoryFilter)5 TextListener (org.junit.internal.TextListener)5 ShardingEnvironment (com.google.testing.junit.runner.sharding.ShardingEnvironment)4