use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class ParameterResolverTests method executeTestsForPrimitiveIntegerMethodInjectionCases.
@Test
void executeTestsForPrimitiveIntegerMethodInjectionCases() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(PrimitiveIntegerMethodInjectionTestCase.class);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed");
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class ParameterResolverTests method executeTestsForPotentiallyIncompatibleTypeMethodInjectionCases.
@Test
void executeTestsForPotentiallyIncompatibleTypeMethodInjectionCases() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(PotentiallyIncompatibleTypeMethodInjectionTestCase.class);
assertEquals(3, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(2, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed");
// @formatter:off
Predicate<String> expectations = s -> s.contains("NumberParameterResolver") && s.contains("resolved a value of type [java.lang.Integer]") && s.contains("but a value assignment compatible with [java.lang.Double] is required");
assertRecordedExecutionEventsContainsExactly(eventRecorder.getFailedTestFinishedEvents(), event(test("doubleParameterInjection"), finishedWithFailure(allOf(isA(ParameterResolutionException.class), message(expectations)))));
// @formatter:on
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestExecutionExceptionHandlerTests method exceptionHandlerConvertsException.
@Test
void exceptionHandlerConvertsException() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(ATestCase.class, "testConvert")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertTrue(ConvertException.handleExceptionCalled, "TestExecutionExceptionHandler should have been called");
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
event(container(ATestCase.class), started()), //
event(test("testConvert"), started()), //
event(test("testConvert"), finishedWithFailure(allOf(isA(IOException.class), message("checked")))), //
event(container(ATestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestExecutionExceptionHandlerTests method exceptionHandlerRethrowsException.
@Test
void exceptionHandlerRethrowsException() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(ATestCase.class, "testRethrow")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertTrue(RethrowException.handleExceptionCalled, "TestExecutionExceptionHandler should have been called");
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
event(container(ATestCase.class), started()), //
event(test("testRethrow"), started()), //
event(test("testRethrow"), finishedWithFailure(allOf(isA(IOException.class), message("checked")))), //
event(container(ATestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class UniqueIdParsingForArrayParameterIntegrationTests method executeTestsForPrimitiveArrayMethodInjectionCases.
@Test
void executeTestsForPrimitiveArrayMethodInjectionCases() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(PrimitiveArrayMethodInjectionTestCase.class);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed");
// @formatter:off
UniqueId uniqueId = eventRecorder.getExecutionEvents().stream().map(ExecutionEvent::getTestDescriptor).distinct().skip(2).map(TestDescriptor::getUniqueId).findFirst().orElseThrow(AssertionError::new);
// @formatter:on
assertThat(UniqueId.parse(uniqueId.toString())).isEqualTo(uniqueId);
}
Aggregations