Search in sources :

Example 51 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class TestTemplateInvocationTests method legacyReportingNames.

@Test
void legacyReportingNames() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithTwoRegisteredExtensions")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    // @formatter:off
    Stream<String> legacyReportingNames = eventRecorder.getExecutionEvents().stream().filter(event -> event.getType() == DYNAMIC_TEST_REGISTERED).map(ExecutionEvent::getTestDescriptor).map(TestDescriptor::getLegacyReportingName);
    // @formatter:off
    assertThat(legacyReportingNames).containsExactly("templateWithTwoRegisteredExtensions()[1]", "templateWithTwoRegisteredExtensions()[2]");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) TestDescriptor(org.junit.platform.engine.TestDescriptor) TestTemplateInvocationTestDescriptor(org.junit.jupiter.engine.descriptor.TestTemplateInvocationTestDescriptor) Test(org.junit.jupiter.api.Test)

Example 52 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class TestTemplateInvocationTests method templateWithTwoRegisteredExtensionsIsInvoked.

@Test
void templateWithTwoRegisteredExtensionsIsInvoked() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithTwoRegisteredExtensions")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithTwoRegisteredExtensions"), 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("templateWithTwoRegisteredExtensions"), finishedSuccessfully())));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 53 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder 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");
    ExecutionEventRecorder eventRecorder = executeTests(selectUniqueId(uniqueId));
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), 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 : DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 54 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class TestTemplateInvocationTests method templateWithCustomizedDisplayNamesIsInvoked.

@Test
void templateWithCustomizedDisplayNamesIsInvoked() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithCustomizedDisplayNames")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithCustomizedDisplayNames"), started()), event(dynamicTestRegistered("test-template-invocation:#1"), // 
    displayName("1 --> templateWithCustomizedDisplayNames()")), // 
    event(test("test-template-invocation:#1"), started()), event(test("test-template-invocation:#1"), // 
    finishedWithFailure(message("invocation is expected to fail"))), event(container("templateWithCustomizedDisplayNames"), finishedSuccessfully())));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 55 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder 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();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), 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 : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Aggregations

ExecutionEventRecorder (org.junit.platform.engine.test.event.ExecutionEventRecorder)114 Test (org.junit.jupiter.api.Test)104 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)74 DynamicTest (org.junit.jupiter.api.DynamicTest)12 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)12 DiscoverySelectors.selectMethod (org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod)12 Method (java.lang.reflect.Method)10 TestDescriptor (org.junit.platform.engine.TestDescriptor)8 IOException (java.io.IOException)6 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)5 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 TestInfo (org.junit.jupiter.api.TestInfo)4 UniqueId (org.junit.platform.engine.UniqueId)4 JupiterTestEngine (org.junit.jupiter.engine.JupiterTestEngine)3 LauncherDiscoveryRequestBuilder.request (org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.request)3 Map (java.util.Map)2 Optional (java.util.Optional)2 Predicate (java.util.function.Predicate)2 Assertions.allOf (org.assertj.core.api.Assertions.allOf)2