use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestTemplateInvocationTests method extensionIsAskedForSupportBeforeItMustProvide.
@Test
void extensionIsAskedForSupportBeforeItMustProvide() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithWrongParameterType", int.class.getName())).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), wrappedInContainerEvents(//
MyTestTemplateTestCase.class, //
event(container("templateWithWrongParameterType"), started()), event(container("templateWithWrongParameterType"), finishedWithFailure(message(s -> s.startsWith("You must register at least one TestTemplateInvocationContextProvider that supports @TestTemplate method ["))))));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestTemplateInvocationTests method templateWithSupportingProviderButNoInvocationsReportsFailure.
@Test
void templateWithSupportingProviderButNoInvocationsReportsFailure() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithSupportingProviderButNoInvocations")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), wrappedInContainerEvents(//
MyTestTemplateTestCase.class, //
event(container("templateWithSupportingProviderButNoInvocations"), started()), event(container("templateWithSupportingProviderButNoInvocations"), finishedWithFailure(message("No supporting TestTemplateInvocationContextProvider provided an invocation context")))));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class AtypicalJvmMethodNameTests method kotlinTestWithMethodNameContainingSpecialCharacters.
@Test
void kotlinTestWithMethodNameContainingSpecialCharacters() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(ArbitraryNamingKotlinTestCase.class);
assertThat(eventRecorder.getTestFinishedCount()).isEqualTo(2);
TestDescriptor testDescriptor1 = eventRecorder.getSuccessfulTestFinishedEvents().get(0).getTestDescriptor();
assertAll(//
() -> assertEquals(METHOD_NAME + "()", testDescriptor1.getDisplayName()), () -> assertEquals(METHOD_NAME + "()", testDescriptor1.getLegacyReportingName()));
TestDescriptor testDescriptor2 = eventRecorder.getSuccessfulTestFinishedEvents().get(1).getTestDescriptor();
assertAll(//
() -> assertEquals("test name ends with parentheses()()", testDescriptor2.getDisplayName()), () -> assertEquals("test name ends with parentheses()()", testDescriptor2.getLegacyReportingName()));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class DefaultMethodTests method executeTestCaseWithOverloadedMethodNextToGenericDefaultMethodSelectedByClass.
@Test
void executeTestCaseWithOverloadedMethodNextToGenericDefaultMethodSelectedByClass() throws Exception {
Class<?> clazz = GenericTestCaseWithDefaultMethod.class;
LauncherDiscoveryRequest request = request().selectors(selectClass(clazz)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
// @formatter:off
assertAll(() -> assertTrue(beforeAllInvoked, "@BeforeAll default method invoked from interface"), () -> assertTrue(afterAllInvoked, "@AfterAll default method invoked from interface"), () -> assertTrue(defaultMethodInvoked, "default @Test method invoked from interface"), () -> assertTrue(localMethodInvoked, "local @Test method invoked from class"), () -> assertEquals(2, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(2, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed"));
// @formatter:on
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class DefaultMethodTests method executeTestCaseWithDefaultMethodFromInterfaceSelectedByFullyQualifedMethodName.
@Test
void executeTestCaseWithDefaultMethodFromInterfaceSelectedByFullyQualifedMethodName() {
String fqmn = TestCaseWithDefaultMethod.class.getName() + "#test";
LauncherDiscoveryRequest request = request().selectors(selectMethod(fqmn)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
// @formatter:off
assertAll(() -> assertTrue(beforeAllInvoked, "@BeforeAll static method invoked from interface"), () -> assertTrue(afterAllInvoked, "@AfterAll static method invoked from interface"), () -> assertTrue(defaultMethodInvoked, "default @Test method invoked from interface"), () -> assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed"));
// @formatter:on
}
Aggregations