Search in sources :

Example 1 with LauncherConfig

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

the class CustomPostDiscoveryFilter method launcherConfig.

@org.junit.jupiter.api.Test
void launcherConfig() {
    Path reportsDir = Paths.get("target", "xml-reports");
    PrintWriter out = new PrintWriter(System.out);
    // @formatter:off
    // tag::launcherConfig[]
    LauncherConfig launcherConfig = LauncherConfig.builder().enableTestEngineAutoRegistration(false).enableLauncherSessionListenerAutoRegistration(false).enableLauncherDiscoveryListenerAutoRegistration(false).enablePostDiscoveryFilterAutoRegistration(false).enableTestExecutionListenerAutoRegistration(false).addTestEngines(new CustomTestEngine()).addLauncherSessionListeners(new CustomLauncherSessionListener()).addLauncherDiscoveryListeners(new CustomLauncherDiscoveryListener()).addPostDiscoveryFilters(new CustomPostDiscoveryFilter()).addTestExecutionListeners(new LegacyXmlReportGeneratingListener(reportsDir, out)).addTestExecutionListeners(new CustomTestExecutionListener()).build();
    LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(selectPackage("com.example.mytests")).build();
    try (LauncherSession session = LauncherFactory.openSession(launcherConfig)) {
        session.getLauncher().execute(request);
    }
// end::launcherConfig[]
// @formatter:on
}
Also used : Path(java.nio.file.Path) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) LegacyXmlReportGeneratingListener(org.junit.platform.reporting.legacy.xml.LegacyXmlReportGeneratingListener) LauncherConfig(org.junit.platform.launcher.core.LauncherConfig) PrintWriter(java.io.PrintWriter) LauncherSession(org.junit.platform.launcher.LauncherSession)

Aggregations

PrintWriter (java.io.PrintWriter)1 Path (java.nio.file.Path)1 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)1 LauncherSession (org.junit.platform.launcher.LauncherSession)1 LauncherConfig (org.junit.platform.launcher.core.LauncherConfig)1 LegacyXmlReportGeneratingListener (org.junit.platform.reporting.legacy.xml.LegacyXmlReportGeneratingListener)1