Search in sources :

Example 21 with Launcher

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

the class DefaultLauncher method discoverRoot.

private Root discoverRoot(LauncherDiscoveryRequest discoveryRequest, String phase) {
    Root root = new Root();
    for (TestEngine testEngine : this.testEngines) {
        // @formatter:off
        boolean engineIsExcluded = discoveryRequest.getEngineFilters().stream().map(engineFilter -> engineFilter.apply(testEngine)).anyMatch(FilterResult::excluded);
        if (engineIsExcluded) {
            logger.debug(() -> String.format("Test discovery for engine '%s' was skipped due to an EngineFilter in phase '%s'.", testEngine.getId(), phase));
            continue;
        }
        logger.debug(() -> String.format("Discovering tests during Launcher %s phase in engine '%s'.", phase, testEngine.getId()));
        Optional<TestDescriptor> engineRoot = discoverEngineRoot(testEngine, discoveryRequest);
        engineRoot.ifPresent(rootDescriptor -> root.add(testEngine, rootDescriptor));
    }
    root.applyPostDiscoveryFilters(discoveryRequest);
    root.prune();
    return root;
}
Also used : Preconditions(org.junit.platform.commons.util.Preconditions) Launcher(org.junit.platform.launcher.Launcher) ConfigurationParameters(org.junit.platform.engine.ConfigurationParameters) TestPlan(org.junit.platform.launcher.TestPlan) Logger(org.junit.platform.commons.logging.Logger) JUnitException(org.junit.platform.commons.JUnitException) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) FilterResult(org.junit.platform.engine.FilterResult) TestEngine(org.junit.platform.engine.TestEngine) Set(java.util.Set) BlacklistedExceptions(org.junit.platform.commons.util.BlacklistedExceptions) UniqueId(org.junit.platform.engine.UniqueId) LoggerFactory(org.junit.platform.commons.logging.LoggerFactory) HashSet(java.util.HashSet) Optional(java.util.Optional) ExecutionRequest(org.junit.platform.engine.ExecutionRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) TestEngine(org.junit.platform.engine.TestEngine) FilterResult(org.junit.platform.engine.FilterResult) TestDescriptor(org.junit.platform.engine.TestDescriptor)

Example 22 with Launcher

use of org.junit.platform.launcher.Launcher in project spock by spockframework.

the class SpockHelloWorldTest method verifyErrorExample.

@Test
void verifyErrorExample() {
    Launcher launcher = LauncherFactory.create(LauncherConfig.builder().enableTestEngineAutoRegistration(false).enableTestExecutionListenerAutoRegistration(false).addTestEngines(new SpockEngine()).build());
    TestPlan testPlan = launcher.discover(LauncherDiscoveryRequestBuilder.request().selectors(selectClass(ErrorTestCase.class)).build());
    assertEquals(1, testPlan.getChildren(testPlan.getRoots().iterator().next()).size());
    execute(selectClass(StepwiseTestCase.class), stats -> stats.started(4).succeeded(3).failed(1).skipped(1));
}
Also used : SpockEngine(org.spockframework.runtime.SpockEngine) TestPlan(org.junit.platform.launcher.TestPlan) Launcher(org.junit.platform.launcher.Launcher) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with Launcher

use of org.junit.platform.launcher.Launcher in project spring-boot by spring-projects.

the class WebMvcTestPrintDefaultIntegrationTests method executeTests.

private void executeTests(Class<?> testClass) {
    LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(DiscoverySelectors.selectClass(testClass)).build();
    Launcher launcher = LauncherFactory.create();
    launcher.execute(request);
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Launcher(org.junit.platform.launcher.Launcher)

Example 24 with Launcher

use of org.junit.platform.launcher.Launcher in project spring-boot by spring-projects.

the class ImportsContextCustomizerFactoryWithAutoConfigurationTests method executeTests.

private void executeTests(Class<?> testClass) {
    LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(DiscoverySelectors.selectClass(testClass)).build();
    Launcher launcher = LauncherFactory.create();
    launcher.execute(request);
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Launcher(org.junit.platform.launcher.Launcher)

Example 25 with Launcher

use of org.junit.platform.launcher.Launcher in project neo4j by neo4j.

the class TestDirectoryExtensionTestSupport method execute.

private static void execute(LauncherDiscoveryRequest discoveryRequest, TestExecutionListener... testExecutionListeners) {
    Launcher launcher = LauncherFactory.create();
    launcher.execute(discoveryRequest, testExecutionListeners);
}
Also used : Launcher(org.junit.platform.launcher.Launcher)

Aggregations

Launcher (org.junit.platform.launcher.Launcher)26 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)16 TestExecutionSummary (org.junit.platform.launcher.listeners.TestExecutionSummary)8 SummaryGeneratingListener (org.junit.platform.launcher.listeners.SummaryGeneratingListener)7 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)6 TestPlan (org.junit.platform.launcher.TestPlan)6 Test (org.junit.jupiter.api.Test)5 ProviderParameters (org.apache.maven.surefire.providerapi.ProviderParameters)3 TestIdentifier (org.junit.platform.launcher.TestIdentifier)3 PrintStream (java.io.PrintStream)2 PrintWriter (java.io.PrintWriter)2 ArrayList (java.util.ArrayList)2 Set (java.util.Set)2 RunListener (org.apache.maven.surefire.report.RunListener)2 SimpleReportEntry (org.apache.maven.surefire.report.SimpleReportEntry)2 TestListResolver (org.apache.maven.surefire.testset.TestListResolver)2 TestsToRun (org.apache.maven.surefire.util.TestsToRun)2 TestExecutionResult (org.junit.platform.engine.TestExecutionResult)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1