use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class AtypicalJvmMethodNameTests method kotlinTestWithMethodNameContainingSpecialCharacters.
@Test
void kotlinTestWithMethodNameContainingSpecialCharacters() {
EngineExecutionResults executionResults = executeTestsForClass(ArbitraryNamingKotlinTestCase.class);
assertThat(executionResults.testEvents().started().count()).isEqualTo(2);
TestDescriptor testDescriptor1 = executionResults.testEvents().succeeded().list().get(0).getTestDescriptor();
assertAll(//
() -> assertEquals(METHOD_NAME + "()", testDescriptor1.getDisplayName()), () -> assertEquals(METHOD_NAME + "()", testDescriptor1.getLegacyReportingName()));
TestDescriptor testDescriptor2 = executionResults.testEvents().succeeded().list().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.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class DefaultMethodTests method executeTestCaseWithOverriddenGenericDefaultMethodSelectedByClass.
@Test
void executeTestCaseWithOverriddenGenericDefaultMethodSelectedByClass() {
Class<?> clazz = GenericTestCaseWithOverriddenDefaultMethod.class;
LauncherDiscoveryRequest request = request().selectors(selectClass(clazz)).build();
EngineExecutionResults executionResults = executeTests(request);
// @formatter:off
assertAll(() -> assertTrue(beforeAllInvoked, "@BeforeAll default method invoked from interface"), () -> assertTrue(afterAllInvoked, "@AfterAll default method invoked from interface"), () -> assertFalse(defaultMethodInvoked, "default @Test method should not have been invoked from interface"), () -> assertTrue(overriddenDefaultMethodInvoked, "overridden default @Test method invoked from interface"), () -> assertTrue(localMethodInvoked, "local @Test method invoked from class"), // should not have been "discovered" since it is overridden.
() -> assertEquals(2, executionResults.testEvents().started().count(), "# tests started"), () -> assertEquals(2, executionResults.testEvents().succeeded().count(), "# tests succeeded"), () -> assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed"));
// @formatter:on
}
use of org.junit.platform.testkit.engine.EngineExecutionResults 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();
EngineExecutionResults executionResults = 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, executionResults.testEvents().started().count(), "# tests started"), () -> assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded"), () -> assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed"));
// @formatter:on
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class DefaultMethodTests method executeTestCaseWithOverloadedMethodNextToGenericDefaultMethodSelectedByClass.
@Test
void executeTestCaseWithOverloadedMethodNextToGenericDefaultMethodSelectedByClass() {
Class<?> clazz = GenericTestCaseWithDefaultMethod.class;
LauncherDiscoveryRequest request = request().selectors(selectClass(clazz)).build();
EngineExecutionResults executionResults = 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, executionResults.testEvents().started().count(), "# tests started"), () -> assertEquals(2, executionResults.testEvents().succeeded().count(), "# tests succeeded"), () -> assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed"));
// @formatter:on
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class DynamicNodeGenerationTests method singleDynamicTestIsExecutedWhenDiscoveredByUniqueId.
@Test
void singleDynamicTestIsExecutedWhenDiscoveredByUniqueId() {
UniqueId uniqueId = //
discoverUniqueId(MyDynamicTestCase.class, "dynamicStream").append(DYNAMIC_TEST_SEGMENT_TYPE, "#2");
EngineExecutionResults executionResults = executeTests(selectUniqueId(uniqueId));
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(MyDynamicTestCase.class), started()), //
event(container("dynamicStream"), started()), //
event(dynamicTestRegistered("dynamic-test:#2")), //
event(test("dynamic-test:#2", "failingTest"), started()), //
event(test("dynamic-test:#2", "failingTest"), finishedWithFailure(message("failing"))), //
event(container("dynamicStream"), finishedSuccessfully()), //
event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
Aggregations