Search in sources :

Example 56 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest 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 57 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest 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 58 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest 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 59 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.

the class TestTemplateInvocationTests method lifecycleCallbacksAreExecutedForInvocation.

@Test
void lifecycleCallbacksAreExecutedForInvocation() {
    LauncherDiscoveryRequest request = request().selectors(selectClass(TestTemplateTestClassWithDynamicLifecycleCallbacks.class)).build();
    executeTests(request);
    // @formatter:off
    assertThat(TestTemplateTestClassWithDynamicLifecycleCallbacks.lifecycleEvents).containsExactly("beforeEach", "beforeTestExecution", "testTemplate:foo", "handleTestExecutionException", "afterTestExecution", "afterEach", "beforeEach", "beforeTestExecution", "testTemplate:bar", "afterTestExecution", "afterEach");
// @formatter:on
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 60 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest 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

LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)158 Test (org.junit.jupiter.api.Test)141 ExecutionEventRecorder (org.junit.platform.engine.test.event.ExecutionEventRecorder)74 TestDescriptor (org.junit.platform.engine.TestDescriptor)54 PlainOldJavaClassWithoutAnyTest (org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest)33 DynamicTest (org.junit.jupiter.api.DynamicTest)12 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)11 DiscoverySelectors.selectMethod (org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod)11 PlainJUnit4TestCaseWithFiveTestMethods (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods)11 Method (java.lang.reflect.Method)9 Launcher (org.junit.platform.launcher.Launcher)9 PlainJUnit4TestCaseWithSingleTestWhichFails (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 SummaryGeneratingListener (org.junit.platform.launcher.listeners.SummaryGeneratingListener)5 Path (java.nio.file.Path)4 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)4 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)4 TestIdentifier (org.junit.platform.launcher.TestIdentifier)4 TestPlan (org.junit.platform.launcher.TestPlan)4