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
}
Aggregations