Search in sources :

Example 76 with JUnitCore

use of org.junit.runner.JUnitCore in project spring-boot by spring-projects.

the class Mockito21Tests method runTests.

private void runTests(Class<?> testClass) {
    Result result = new JUnitCore().run(testClass);
    for (Failure failure : result.getFailures()) {
        System.err.println(failure.getTrace());
    }
    assertThat(result.getFailureCount()).isEqualTo(0);
    assertThat(result.getRunCount()).isGreaterThan(0);
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result)

Example 77 with JUnitCore

use of org.junit.runner.JUnitCore in project spring-boot by spring-projects.

the class Mockito22Tests method runTests.

private void runTests(Class<?> testClass) {
    Result result = new JUnitCore().run(testClass);
    for (Failure failure : result.getFailures()) {
        System.err.println(failure.getTrace());
    }
    assertThat(result.getFailureCount()).isEqualTo(0);
    assertThat(result.getRunCount()).isGreaterThan(0);
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result)

Example 78 with JUnitCore

use of org.junit.runner.JUnitCore in project spring-boot by spring-projects.

the class Mockito25Tests method runTests.

private void runTests(Class<?> testClass) {
    Result result = new JUnitCore().run(testClass);
    for (Failure failure : result.getFailures()) {
        System.err.println(failure.getTrace());
    }
    assertThat(result.getFailureCount()).isEqualTo(0);
    assertThat(result.getRunCount()).isGreaterThan(0);
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result)

Example 79 with JUnitCore

use of org.junit.runner.JUnitCore in project spring-framework by spring-projects.

the class JUnitTestingUtils method runTestsAndAssertCounters.

/**
	 * Run all tests in the supplied test classes according to the policies of
	 * the supplied {@link Computer}, using the {@link Runner} configured via
	 * {@link RunWith @RunWith} or the default JUnit runner, and assert the
	 * expectations of the test execution.
	 *
	 * <p>To have all tests executed in parallel, supply {@link ParallelComputer#methods()}
	 * as the {@code Computer}. To have all tests executed serially, supply
	 * {@link Computer#serial()} as the {@code Computer}.
	 *
	 * @param computer the JUnit {@code Computer} to use
	 * @param expectedStartedCount the expected number of tests that started
	 * @param expectedFailedCount the expected number of tests that failed
	 * @param expectedFinishedCount the expected number of tests that finished
	 * @param expectedIgnoredCount the expected number of tests that were ignored
	 * @param expectedAssumptionFailedCount the expected number of tests that
	 * resulted in a failed assumption
	 * @param testClasses one or more test classes to run
	 */
public static void runTestsAndAssertCounters(Computer computer, int expectedStartedCount, int expectedFailedCount, int expectedFinishedCount, int expectedIgnoredCount, int expectedAssumptionFailedCount, Class<?>... testClasses) throws Exception {
    JUnitCore junit = new JUnitCore();
    TrackingRunListener listener = new TrackingRunListener();
    junit.addListener(listener);
    junit.run(computer, testClasses);
    // @formatter:off
    assertAll(() -> assertEquals(expectedStartedCount, listener.getTestStartedCount(), "tests started"), () -> assertEquals(expectedFailedCount, listener.getTestFailureCount(), "tests failed"), () -> assertEquals(expectedFinishedCount, listener.getTestFinishedCount(), "tests finished"), () -> assertEquals(expectedIgnoredCount, listener.getTestIgnoredCount(), "tests ignored"), () -> assertEquals(expectedAssumptionFailedCount, listener.getTestAssumptionFailureCount(), "failed assumptions"));
// @formatter:on
}
Also used : JUnitCore(org.junit.runner.JUnitCore)

Example 80 with JUnitCore

use of org.junit.runner.JUnitCore in project ddf by codice.

the class PaxExamRuleTest method failingBeforeExam.

@Test
public void failingBeforeExam() {
    JUnitCore core = new JUnitCore();
    Result result = core.run(FailingBeforeExamTest.class);
    boolean examFail = result.getFailures().stream().anyMatch(failure -> failure.getMessage().equals(PaxExamRule.EXAM_SETUP_FAILED_MESSAGE));
    boolean beforeExamFail = result.getFailures().stream().anyMatch(failure -> failure.getMessage().contains(EXPECTED_BEFORE_EXAM_ERROR_MESSAGE));
    assertThat(examFail && beforeExamFail);
    assertResultCounts(result, 4);
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) 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