Search in sources :

Example 61 with LauncherDiscoveryRequest

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

Example 62 with LauncherDiscoveryRequest

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

the class TestTemplateInvocationTests method templateWithSupportingProviderButNoInvocationsReportsFailure.

@Test
void templateWithSupportingProviderButNoInvocationsReportsFailure() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithSupportingProviderButNoInvocations")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithSupportingProviderButNoInvocations"), started()), event(container("templateWithSupportingProviderButNoInvocations"), finishedWithFailure(message("No supporting TestTemplateInvocationContextProvider provided an invocation context")))));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 63 with LauncherDiscoveryRequest

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

the class DefaultMethodTests method executeTestCaseWithOverloadedMethodNextToGenericDefaultMethodSelectedByClass.

@Test
void executeTestCaseWithOverloadedMethodNextToGenericDefaultMethodSelectedByClass() throws Exception {
    Class<?> clazz = GenericTestCaseWithDefaultMethod.class;
    LauncherDiscoveryRequest request = request().selectors(selectClass(clazz)).build();
    ExecutionEventRecorder eventRecorder = 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, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(2, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed"));
// @formatter:on
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 64 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest 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();
    ExecutionEventRecorder eventRecorder = 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, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed"));
// @formatter:on
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 65 with LauncherDiscoveryRequest

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

the class DefaultMethodTests method executeTestCaseWithOverriddenGenericDefaultMethodSelectedByClass.

@Test
void executeTestCaseWithOverriddenGenericDefaultMethodSelectedByClass() throws Exception {
    Class<?> clazz = GenericTestCaseWithOverriddenDefaultMethod.class;
    LauncherDiscoveryRequest request = request().selectors(selectClass(clazz)).build();
    ExecutionEventRecorder eventRecorder = 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, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(2, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed"));
// @formatter:on
}
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