Search in sources :

Example 1 with EngineExecutionResults

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()));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 2 with EngineExecutionResults

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
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 3 with EngineExecutionResults

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
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 4 with EngineExecutionResults

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
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 5 with EngineExecutionResults

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()));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) UniqueId(org.junit.platform.engine.UniqueId) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Aggregations

EngineExecutionResults (org.junit.platform.testkit.engine.EngineExecutionResults)139 Test (org.junit.jupiter.api.Test)134 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)32 DynamicTest (org.junit.jupiter.api.DynamicTest)30 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)30 Events (org.junit.platform.testkit.engine.Events)27 DisplayName (org.junit.jupiter.api.DisplayName)15 RepeatedTest (org.junit.jupiter.api.RepeatedTest)15 IOException (java.io.IOException)12 Execution (org.junit.platform.testkit.engine.Execution)12 TimeoutException (java.util.concurrent.TimeoutException)10 List (java.util.List)8 ExtensionConfigurationException (org.junit.jupiter.api.extension.ExtensionConfigurationException)8 ArrayList (java.util.ArrayList)7 AfterAll (org.junit.jupiter.api.AfterAll)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 BeforeAll (org.junit.jupiter.api.BeforeAll)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 Nested (org.junit.jupiter.api.Nested)7 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)7