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);
}
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);
}
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);
}
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
}
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);
}
Aggregations