use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class BeforeAndAfterTestExecutionCallbackTests method beforeEachMethodThrowsAnException.
@Test
void beforeEachMethodThrowsAnException() {
EngineExecutionResults executionResults = executeTestsForClass(ExceptionInBeforeEachMethodTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(0, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
assertEquals(1, executionResults.testEvents().failed().count(), "# tests failed");
// @formatter:off
assertEquals(asList(// throws an exception.
"beforeEachMethod", // fooAfterTestExecutionCallback should not get invoked.
"afterEachMethod"), callSequence, "wrong call sequence");
// @formatter:on
assertNull(actualExceptionInAfterTestExecution, "test exception (fooAfterTestExecutionCallback should not have been called)");
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class BeforeAndAfterTestExecutionCallbackTests method beforeTestExecutionCallbackThrowsAnException.
@Test
void beforeTestExecutionCallbackThrowsAnException() {
EngineExecutionResults executionResults = executeTestsForClass(ExceptionInBeforeTestExecutionCallbackTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(0, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
assertEquals(1, executionResults.testEvents().failed().count(), "# tests failed");
// @formatter:off
assertEquals(asList("beforeEachMethod", "fooBeforeTestExecutionCallback", // throws an exception.
"exceptionThrowingBeforeTestExecutionCallback", // test() should not get invoked.
"barAfterTestExecutionCallback", "fooAfterTestExecutionCallback", "afterEachMethod"), callSequence, "wrong call sequence");
// @formatter:on
assertNotNull(actualExceptionInAfterTestExecution, "test exception");
assertTrue(actualExceptionInAfterTestExecution.isPresent(), "test exception should be present");
assertEquals(EnigmaException.class, actualExceptionInAfterTestExecution.get().getClass());
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class BeforeAndAfterTestExecutionCallbackTests method afterTestExecutionCallbackThrowsAnException.
@Test
void afterTestExecutionCallbackThrowsAnException() {
EngineExecutionResults executionResults = executeTestsForClass(ExceptionInAfterTestExecutionCallbackTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(0, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
assertEquals(1, executionResults.testEvents().failed().count(), "# tests failed");
// @formatter:off
assertEquals(asList("beforeEachMethod", "fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "test", "barAfterTestExecutionCallback", // throws an exception.
"exceptionThrowingAfterTestExecutionCallback", "fooAfterTestExecutionCallback", "afterEachMethod"), callSequence, "wrong call sequence");
// @formatter:on
assertNotNull(actualExceptionInAfterTestExecution, "test exception");
assertTrue(actualExceptionInAfterTestExecution.isPresent(), "test exception should be present");
assertEquals(EnigmaException.class, actualExceptionInAfterTestExecution.get().getClass());
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ExecutionConditionTests method conditionWorksOnContainer.
@Test
void conditionWorksOnContainer() {
EngineExecutionResults executionResults = executeTestsForClass(TestCaseWithExecutionConditionOnClass.class);
executionResults.containerEvents().assertStatistics(stats -> stats.skipped(1));
executionResults.testEvents().assertStatistics(stats -> stats.started(0));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ExecutionConditionTests method assertExecutionConditionOverride.
private void assertExecutionConditionOverride(String deactivatePattern, int testStartedCount, int testFailedCount) {
// @formatter:off
LauncherDiscoveryRequest request = request().selectors(selectClass(TestCaseWithExecutionConditionOnClass.class)).configurationParameter(DEACTIVATE_CONDITIONS_PATTERN_PROPERTY_NAME, deactivatePattern).build();
// @formatter:on
EngineExecutionResults executionResults = executeTests(request);
Events containers = executionResults.containerEvents();
Events tests = executionResults.testEvents();
containers.assertStatistics(stats -> stats.skipped(0).started(2));
tests.assertStatistics(stats -> stats.started(testStartedCount).failed(testFailedCount));
}
Aggregations