Search in sources :

Example 11 with Result

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

the class CategoryTest method sameAsNoIncludeCategoryAnnotation.

@Test
public void sameAsNoIncludeCategoryAnnotation() {
    Result testResult = JUnitCore.runClasses(SameAsNoIncludeCategoryAnnotationSuite.class);
    assertTrue(testResult.wasSuccessful());
    assertEquals(1, testResult.getRunCount());
}
Also used : Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult) Test(org.junit.Test)

Example 12 with Result

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

the class CategoryTest method testCountWithExplicitExcludeFilter.

@Test
public void testCountWithExplicitExcludeFilter() throws Throwable {
    CategoryFilter include = CategoryFilter.exclude(SlowTests.class);
    Request baseRequest = Request.aClass(TestSuiteWithNoCategories.class);
    Result result = new JUnitCore().run(baseRequest.filterWith(include));
    assertEquals(2, result.getFailureCount());
    assertEquals(2, result.getRunCount());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Request(org.junit.runner.Request) CategoryFilter(org.junit.experimental.categories.Categories.CategoryFilter) Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult) Test(org.junit.Test)

Example 13 with Result

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

the class CategoryTest method testInheritance.

@Test
public void testInheritance() {
    Result result = JUnitCore.runClasses(InheritanceSuite.class);
    assertEquals(1, result.getRunCount());
    assertTrue(result.wasSuccessful());
}
Also used : Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult) Test(org.junit.Test)

Example 14 with Result

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

the class CategoryTest method ignoredTest.

@Test
public void ignoredTest() {
    // behaves same as Suite
    Result result = JUnitCore.runClasses(IgnoredTestCategoriesSuite.class);
    assertFalse(result.wasSuccessful());
    assertThat(result.getRunCount(), is(1));
    assertThat(result.getFailureCount(), is(1));
    assertThat(result.getIgnoreCount(), is(1));
}
Also used : Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult) Test(org.junit.Test)

Example 15 with Result

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

the class StackTracesTest method getTrimmedStackForJUnit4TestFailingInMethodRule.

@Test
public void getTrimmedStackForJUnit4TestFailingInMethodRule() {
    Result result = runTest(TestWithThrowingMethodRule.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$ThrowingMethodRule.apply"));
    assertNotEquals(failure.getTrace(), failure.getTrimmedTrace());
}
Also used : Failure(org.junit.runner.notification.Failure) 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