Search in sources :

Example 1 with LauncherDiscoveryRequest

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

the class ConsoleTestExecutor method executeTests.

private TestExecutionSummary executeTests(PrintWriter out) {
    Launcher launcher = launcherSupplier.get();
    SummaryGeneratingListener summaryListener = registerListeners(out, launcher);
    LauncherDiscoveryRequest discoveryRequest = new DiscoveryRequestCreator().toDiscoveryRequest(options);
    launcher.execute(discoveryRequest);
    TestExecutionSummary summary = summaryListener.getSummary();
    if (summary.getTotalFailureCount() > 0 || options.getDetails() != Details.NONE) {
        printSummary(summary, out);
    }
    return summary;
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) SummaryGeneratingListener(org.junit.platform.launcher.listeners.SummaryGeneratingListener) TestExecutionSummary(org.junit.platform.launcher.listeners.TestExecutionSummary) Launcher(org.junit.platform.launcher.Launcher)

Example 2 with LauncherDiscoveryRequest

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

the class JUnitPlatformRunnerTests method instantiateRunnerAndCaptureGeneratedRequest.

private LauncherDiscoveryRequest instantiateRunnerAndCaptureGeneratedRequest(Class<?> testClass) throws InitializationError {
    Launcher launcher = mock(Launcher.class);
    ArgumentCaptor<LauncherDiscoveryRequest> captor = ArgumentCaptor.forClass(LauncherDiscoveryRequest.class);
    when(launcher.discover(captor.capture())).thenReturn(TestPlan.from(emptySet()));
    new JUnitPlatform(testClass, launcher);
    return captor.getValue();
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Launcher(org.junit.platform.launcher.Launcher) LauncherFactoryForTestingPurposesOnly.createLauncher(org.junit.platform.launcher.core.LauncherFactoryForTestingPurposesOnly.createLauncher)

Example 3 with LauncherDiscoveryRequest

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

the class DiscoveryRequestCreatorTests method convertsDefaultIncludeClassNamePatternOption.

@Test
void convertsDefaultIncludeClassNamePatternOption() {
    options.setScanClasspath(true);
    LauncherDiscoveryRequest request = convert();
    List<ClassNameFilter> filter = request.getFiltersByType(ClassNameFilter.class);
    assertThat(filter).hasSize(1);
    assertThat(filter.get(0).toString()).contains(STANDARD_INCLUDE_PATTERN);
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ClassNameFilter(org.junit.platform.engine.discovery.ClassNameFilter) Test(org.junit.jupiter.api.Test)

Example 4 with LauncherDiscoveryRequest

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

the class DiscoveryRequestCreatorTests method convertsScanClasspathOptionWithExplicitRootDirectories.

@Test
void convertsScanClasspathOptionWithExplicitRootDirectories() {
    options.setScanClasspath(true);
    options.setSelectedClasspathEntries(asList(Paths.get("."), Paths.get("..")));
    LauncherDiscoveryRequest request = convert();
    List<ClasspathRootSelector> classpathRootSelectors = request.getSelectorsByType(ClasspathRootSelector.class);
    // @formatter:off
    assertThat(classpathRootSelectors).extracting(ClasspathRootSelector::getClasspathRoot).containsExactly(new File(".").toURI(), new File("..").toURI());
// @formatter:on
}
Also used : ClasspathRootSelector(org.junit.platform.engine.discovery.ClasspathRootSelector) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 5 with LauncherDiscoveryRequest

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

the class DiscoveryRequestCreatorTests method convertsScanClasspathOptionWithAdditionalClasspathEntries.

@Test
void convertsScanClasspathOptionWithAdditionalClasspathEntries() {
    options.setScanClasspath(true);
    options.setAdditionalClasspathEntries(asList(Paths.get("."), Paths.get("..")));
    LauncherDiscoveryRequest request = convert();
    List<ClasspathRootSelector> classpathRootSelectors = request.getSelectorsByType(ClasspathRootSelector.class);
    // @formatter:off
    assertThat(classpathRootSelectors).extracting(ClasspathRootSelector::getClasspathRoot).contains(new File(".").toURI(), new File("..").toURI());
// @formatter:on
}
Also used : ClasspathRootSelector(org.junit.platform.engine.discovery.ClasspathRootSelector) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)166 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)15 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)5 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