use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ProgrammaticExtensionRegistrationTests method assertClassFails.
private void assertClassFails(Class<?> testClass, Condition<Throwable> causeCondition) {
EngineExecutionResults executionResults = executeTestsForClass(testClass);
executionResults.containerEvents().assertThatEvents().haveExactly(1, finishedWithFailure(causeCondition));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class BeforeAndAfterTestExecutionCallbackTests method beforeAndAfterTestExecutionCallbacksDeclaredOnSuperclassAndSubclass.
@Test
void beforeAndAfterTestExecutionCallbacksDeclaredOnSuperclassAndSubclass() {
EngineExecutionResults executionResults = executeTestsForClass(ChildTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
// @formatter:off
assertEquals(asList("fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "testChild", "barAfterTestExecutionCallback", "fooAfterTestExecutionCallback"), callSequence, "wrong call sequence");
// @formatter:on
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class BeforeAndAfterTestExecutionCallbackTests method beforeAndAfterTestExecutionCallbacksDeclaredOnInterfaceAndClass.
@Test
void beforeAndAfterTestExecutionCallbacksDeclaredOnInterfaceAndClass() {
EngineExecutionResults executionResults = executeTestsForClass(TestInterfaceTestCase.class);
assertEquals(2, executionResults.testEvents().started().count(), "# tests started");
assertEquals(2, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
// @formatter:off
assertEquals(asList(// Test Interface
"fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "defaultTestMethod", "barAfterTestExecutionCallback", "fooAfterTestExecutionCallback", // Test Class
"fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "localTestMethod", "barAfterTestExecutionCallback", "fooAfterTestExecutionCallback"), callSequence, "wrong call sequence");
// @formatter:on
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class BeforeAndAfterTestExecutionCallbackTests method testMethodThrowsAnException.
@Test
void testMethodThrowsAnException() {
EngineExecutionResults executionResults = executeTestsForClass(ExceptionInTestMethodTestCase.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.
"test", "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 beforeAndAfterTestExecutionCallbacks.
@Test
void beforeAndAfterTestExecutionCallbacks() {
EngineExecutionResults executionResults = executeTestsForClass(OuterTestCase.class);
assertEquals(2, executionResults.testEvents().started().count(), "# tests started");
assertEquals(2, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
// @formatter:off
assertEquals(asList(// OuterTestCase
"beforeEachMethodOuter", "fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "testOuter", "barAfterTestExecutionCallback", "fooAfterTestExecutionCallback", "afterEachMethodOuter", // InnerTestCase
"beforeEachMethodOuter", "beforeEachMethodInner", "fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "fizzBeforeTestExecutionCallback", "testInner", "fizzAfterTestExecutionCallback", "barAfterTestExecutionCallback", "fooAfterTestExecutionCallback", "afterEachMethodInner", "afterEachMethodOuter"), callSequence, "wrong call sequence");
// @formatter:on
}
Aggregations