use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestInstancePostProcessorTests method instancePostProcessorsInNestedClasses.
@Test
void instancePostProcessorsInNestedClasses() {
LauncherDiscoveryRequest request = request().selectors(selectClass(OuterTestCase.class)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(2, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(2, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
// @formatter:off
assertThat(callSequence).containsExactly(// OuterTestCase
"fooPostProcessTestInstance:OuterTestCase", "beforeOuterMethod", "testOuter", "fooPostProcessTestInstance:OuterTestCase", "fooPostProcessTestInstance:InnerTestCase", "barPostProcessTestInstance:InnerTestCase", "beforeOuterMethod", "beforeInnerMethod", "testInner");
// @formatter:on
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestInstancePostProcessorTests method testSpecificTestInstancePostProcessorIsCalled.
@Test
void testSpecificTestInstancePostProcessorIsCalled() {
LauncherDiscoveryRequest request = request().selectors(selectClass(TestCaseWithTestSpecificTestInstancePostProcessor.class)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertThat(callSequence).containsExactly("fooPostProcessTestInstance:TestCaseWithTestSpecificTestInstancePostProcessor", "beforeEachMethod", "test");
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class ExpectedExceptionSupportTests method expectedExceptionIsProcessedCorrectly.
@Test
void expectedExceptionIsProcessedCorrectly() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(ExpectedExceptionTestCase.class);
assertEquals(4, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(0, eventRecorder.getTestAbortedCount(), "# tests aborted");
assertEquals(3, eventRecorder.getTestFailedCount(), "# tests failed");
assertThat(eventRecorder.getSuccessfulTestFinishedEvents()).have(event(test("correctExceptionExpectedThrown"), finishedSuccessfully()));
//
assertThat(eventRecorder.getFailedTestFinishedEvents()).haveExactly(//
1, event(//
test("noExceptionExpectedButThrown"), //
finishedWithFailure(message("no exception expected")))).haveExactly(//
1, event(//
test("exceptionExpectedButNotThrown"), finishedWithFailure(allOf(//
isA(AssertionError.class), //
message("Expected test to throw an instance of java.lang.RuntimeException"))))).haveExactly(//
1, event(//
test("wrongExceptionExpected"), finishedWithFailure(allOf(//
isA(AssertionError.class), message(value -> value.contains("Expected: an instance of java.io.IOException"))))));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class ExpectedExceptionSupportTests method expectedExceptionSupportWithoutExpectedExceptionRule.
@Test
void expectedExceptionSupportWithoutExpectedExceptionRule() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(ExpectedExceptionSupportWithoutExpectedExceptionRuleTestCase.class);
assertEquals(2, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(0, eventRecorder.getTestAbortedCount(), "# tests aborted");
assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed");
assertThat(eventRecorder.getSuccessfulTestFinishedEvents()).have(event(test("success"), finishedSuccessfully()));
//
assertThat(eventRecorder.getFailedTestFinishedEvents()).haveExactly(1, event(//
test("failure"), finishedWithFailure(message("must fail"))));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class LauncherBasedEnableRuleMigrationSupportTests method executeTests.
private ExecutionEventRecorder executeTests(LauncherDiscoveryRequest request) {
TestDescriptor testDescriptor = discoverTests(request);
ExecutionEventRecorder eventRecorder = new ExecutionEventRecorder();
engine.execute(new ExecutionRequest(testDescriptor, eventRecorder, request.getConfigurationParameters()));
return eventRecorder;
}
Aggregations