Search in sources :

Example 71 with ExecutionEventRecorder

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

the class TestTemplateInvocationTests method templateWithCloseableStream.

@Test
void templateWithCloseableStream() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithCloseableStream")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertThat(InvocationContextProviderWithCloseableStream.streamClosed.get()).describedAs("streamClosed").isTrue();
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithCloseableStream"), started()), // 
    event(dynamicTestRegistered("test-template-invocation:#1")), // 
    event(test("test-template-invocation:#1"), started()), // 
    event(test("test-template-invocation:#1"), finishedSuccessfully()), event(container("templateWithCloseableStream"), finishedSuccessfully())));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 72 with ExecutionEventRecorder

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

the class TestTemplateInvocationTests method templateWithDynamicTestInstancePostProcessorIsInvoked.

@Test
void templateWithDynamicTestInstancePostProcessorIsInvoked() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithDynamicTestInstancePostProcessor")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithDynamicTestInstancePostProcessor"), started()), // 
    event(dynamicTestRegistered("test-template-invocation:#1")), // 
    event(test("test-template-invocation:#1"), started()), // 
    event(test("test-template-invocation:#1"), finishedWithFailure(message("foo"))), // 
    event(dynamicTestRegistered("test-template-invocation:#2")), // 
    event(test("test-template-invocation:#2"), started()), // 
    event(test("test-template-invocation:#2"), finishedWithFailure(message("bar"))), event(container("templateWithDynamicTestInstancePostProcessor"), finishedSuccessfully())));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 73 with ExecutionEventRecorder

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

the class TestTemplateInvocationTests method templateWithDisabledInvocationsIsSkipped.

@Test
void templateWithDisabledInvocationsIsSkipped() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithDisabledInvocations")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithDisabledInvocations"), started()), // 
    event(dynamicTestRegistered("test-template-invocation:#1")), // 
    event(test("test-template-invocation:#1"), skippedWithReason("always disabled")), event(container("templateWithDisabledInvocations"), finishedSuccessfully())));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 74 with ExecutionEventRecorder

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

the class TestTemplateInvocationTests method templateWithDynamicParameterResolverIsInvoked.

@Test
void templateWithDynamicParameterResolverIsInvoked() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithDynamicParameterResolver", "java.lang.String")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithDynamicParameterResolver"), started()), // 
    event(dynamicTestRegistered("test-template-invocation:#1"), displayName("[1] foo")), // 
    event(test("test-template-invocation:#1"), started()), // 
    event(test("test-template-invocation:#1"), finishedWithFailure(message("foo"))), // 
    event(dynamicTestRegistered("test-template-invocation:#2"), displayName("[2] bar")), // 
    event(test("test-template-invocation:#2"), started()), // 
    event(test("test-template-invocation:#2"), finishedWithFailure(message("bar"))), event(container("templateWithDynamicParameterResolver"), finishedSuccessfully())));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 75 with ExecutionEventRecorder

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

the class TestTemplateInvocationTests method parentChildRelationshipIsEstablished.

@Test
void parentChildRelationshipIsEstablished() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithSingleRegisteredExtension")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    TestDescriptor templateMethodDescriptor = findTestDescriptor(eventRecorder, container("templateWithSingleRegisteredExtension"));
    TestDescriptor invocationDescriptor = findTestDescriptor(eventRecorder, test("test-template-invocation:#1"));
    assertThat(invocationDescriptor.getParent()).hasValue(templateMethodDescriptor);
    assertThat(templateMethodDescriptor.getChildren()).isEqualTo(singleton(invocationDescriptor));
}
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)

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