Search in sources :

Example 36 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class TestTemplateInvocationTests method legacyReportingNames.

@Test
void legacyReportingNames() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithTwoRegisteredExtensions")).build();
    EngineExecutionResults results = executeTests(request);
    Events events = results.allEvents();
    events.assertStatistics(stats -> stats.dynamicallyRegistered(2));
    // events.dynamicallyRegistered().debug();
    // results.testEvents().dynamicallyRegistered().debug();
    // results.containerEvents().dynamicallyRegistered().debug();
    // @formatter:off
    Stream<String> legacyReportingNames = events.dynamicallyRegistered().map(Event::getTestDescriptor).map(TestDescriptor::getLegacyReportingName);
    // @formatter:off
    assertThat(legacyReportingNames).containsExactly("templateWithTwoRegisteredExtensions()[1]", "templateWithTwoRegisteredExtensions()[2]");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Events(org.junit.platform.testkit.engine.Events) TestDescriptor(org.junit.platform.engine.TestDescriptor) TestTemplateInvocationTestDescriptor(org.junit.jupiter.engine.descriptor.TestTemplateInvocationTestDescriptor) Test(org.junit.jupiter.api.Test)

Example 37 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class TestTemplateInvocationTests method templateWithTwoInvocationsFromSingleExtensionIsInvoked.

@Test
void templateWithTwoInvocationsFromSingleExtensionIsInvoked() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithTwoInvocationsFromSingleExtension")).build();
    EngineExecutionResults executionResults = executeTests(request);
    // 
    executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithTwoInvocationsFromSingleExtension"), started()), // 
    event(dynamicTestRegistered("test-template-invocation:#1"), displayName("[1]")), // 
    event(test("test-template-invocation:#1"), started()), event(test("test-template-invocation:#1"), // 
    finishedWithFailure(message("invocation is expected to fail"))), // 
    event(dynamicTestRegistered("test-template-invocation:#2"), displayName("[2]")), // 
    event(test("test-template-invocation:#2"), started()), event(test("test-template-invocation:#2"), // 
    finishedWithFailure(message("invocation is expected to fail"))), event(container("templateWithTwoInvocationsFromSingleExtension"), finishedSuccessfully())));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 38 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class TestTemplateInvocationTests method singleInvocationIsExecutedWhenDiscoveredByUniqueId.

@Test
void singleInvocationIsExecutedWhenDiscoveredByUniqueId() {
    UniqueId uniqueId = discoverUniqueId(MyTestTemplateTestCase.class, // 
    "templateWithTwoInvocationsFromSingleExtension").append(TestTemplateInvocationTestDescriptor.SEGMENT_TYPE, "#2");
    EngineExecutionResults executionResults = executeTests(selectUniqueId(uniqueId));
    // 
    executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithTwoInvocationsFromSingleExtension"), started()), // 
    event(dynamicTestRegistered("test-template-invocation:#2"), displayName("[2]")), // 
    event(test("test-template-invocation:#2"), started()), event(test("test-template-invocation:#2"), // 
    finishedWithFailure(message("invocation is expected to fail"))), event(container("templateWithTwoInvocationsFromSingleExtension"), finishedSuccessfully())));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) Test(org.junit.jupiter.api.Test)

Example 39 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class TestTemplateInvocationTests method contextParameterResolverCanResolveConstructorArguments.

@Test
void contextParameterResolverCanResolveConstructorArguments() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCaseWithConstructor.class, "template", "java.lang.String")).build();
    EngineExecutionResults executionResults = executeTests(request);
    // 
    executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("template"), started()), // 
    event(dynamicTestRegistered("test-template-invocation:#1"), displayName("[1] foo")), // 
    event(test("test-template-invocation:#1"), started()), // 
    event(test("test-template-invocation:#1"), finishedSuccessfully()), // 
    event(dynamicTestRegistered("test-template-invocation:#2"), displayName("[2] bar")), // 
    event(test("test-template-invocation:#2"), started()), // 
    event(test("test-template-invocation:#2"), finishedSuccessfully()), event(container("template"), finishedSuccessfully())));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 40 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults 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();
    EngineExecutionResults executionResults = executeTests(request);
    // 
    executionResults.allEvents().assertEventsMatchExactly(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 ["))))));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

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