Search in sources :

Example 31 with LauncherDiscoveryRequest

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

the class DiscoveryTests method discoverMethodByUniqueId.

@Test
void discoverMethodByUniqueId() {
    LauncherDiscoveryRequest request = request().selectors(selectUniqueId(JupiterUniqueIdBuilder.uniqueIdForMethod(LocalTestCase.class, "test1()"))).build();
    TestDescriptor engineDescriptor = discoverTests(request);
    assertEquals(2, engineDescriptor.getDescendants().size(), "# resolved test descriptors");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 32 with LauncherDiscoveryRequest

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

the class DiscoveryTests method discoverMultipleMethodsOfSameClass.

@Test
void discoverMultipleMethodsOfSameClass() throws NoSuchMethodException {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(LocalTestCase.class, "test1"), selectMethod(LocalTestCase.class, "test2")).build();
    TestDescriptor engineDescriptor = discoverTests(request);
    assertThat(engineDescriptor.getChildren()).hasSize(1);
    TestDescriptor classDescriptor = getOnlyElement(engineDescriptor.getChildren());
    assertThat(classDescriptor.getChildren()).hasSize(2);
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 33 with LauncherDiscoveryRequest

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

the class TestPlanScannerFilter method accept.

@Override
@SuppressWarnings("rawtypes")
public boolean accept(Class testClass) {
    // @formatter:off
    LauncherDiscoveryRequest discoveryRequest = request().selectors(selectClass(testClass)).filters(includeAndExcludeFilters).build();
    // @formatter:on
    TestPlan testPlan = launcher.discover(discoveryRequest);
    return testPlan.containsTests();
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestPlan(org.junit.platform.launcher.TestPlan)

Example 34 with LauncherDiscoveryRequest

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

the class DisabledTests method executeTestsWithDisabledTestClass.

@Test
void executeTestsWithDisabledTestClass() {
    LauncherDiscoveryRequest request = request().selectors(selectClass(DisabledTestClassTestCase.class)).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertEquals(1, eventRecorder.getContainerSkippedCount(), "# container skipped");
    assertEquals(0, eventRecorder.getTestStartedCount(), "# tests started");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 35 with LauncherDiscoveryRequest

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

the class DisabledTests method executeTestsWithDisabledTestMethods.

@Test
void executeTestsWithDisabledTestMethods() throws Exception {
    LauncherDiscoveryRequest request = request().selectors(selectClass(DisabledTestMethodsTestCase.class)).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
    assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
    assertEquals(1, eventRecorder.getTestSkippedCount(), "# tests skipped");
    String method = DisabledTestMethodsTestCase.class.getDeclaredMethod("disabledTest").toString();
    String reason = eventRecorder.getSkippedTestEvents().get(0).getPayload(String.class).get();
    assertEquals(method + " is @Disabled", reason);
}
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)167 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 Launcher (org.junit.platform.launcher.Launcher)16 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)10 PlainJUnit4TestCaseWithSingleTestWhichFails (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails)8 IOException (java.io.IOException)7 SummaryGeneratingListener (org.junit.platform.launcher.listeners.SummaryGeneratingListener)7 ArrayList (java.util.ArrayList)6 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)6 TestIdentifier (org.junit.platform.launcher.TestIdentifier)5 TestPlan (org.junit.platform.launcher.TestPlan)5 Path (java.nio.file.Path)4 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)4