use of org.junit.platform.launcher.Launcher in project junit5 by junit-team.
the class MyTestClass method execution.
@org.junit.jupiter.api.Test
void execution() {
// @formatter:off
// tag::execution[]
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(selectPackage("com.example.mytests"), selectClass(MyTestClass.class)).filters(includeClassNamePatterns(".*Tests")).build();
Launcher launcher = LauncherFactory.create();
// Register a listener of your choice
TestExecutionListener listener = new SummaryGeneratingListener();
launcher.registerTestExecutionListeners(listener);
launcher.execute(request);
// end::execution[]
// @formatter:on
}
use of org.junit.platform.launcher.Launcher in project junit5 by junit-team.
the class MyTestClass method discovery.
@org.junit.jupiter.api.Test
@SuppressWarnings("unused")
void discovery() {
// @formatter:off
// tag::discovery[]
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(selectPackage("com.example.mytests"), selectClass(MyTestClass.class)).filters(includeClassNamePatterns(".*Tests")).build();
Launcher launcher = LauncherFactory.create();
TestPlan testPlan = launcher.discover(request);
// end::discovery[]
// @formatter:on
}
use of org.junit.platform.launcher.Launcher in project junit5 by junit-team.
the class JUnit4ParameterizedTests method executeTests.
private void executeTests(DiscoverySelector selector) {
Launcher launcher = LauncherFactory.create();
launcher.registerTestExecutionListeners(new StatusTrackingListener());
// @formatter:off
launcher.execute(request().selectors(selector).filters(includeEngines("junit-vintage")).build());
// @formatter:on
}
use of org.junit.platform.launcher.Launcher in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method execute.
private Map<TestIdentifier, TestExecutionResult> execute(LauncherDiscoveryRequestBuilder requestBuilder) {
Map<TestIdentifier, TestExecutionResult> results = new LinkedHashMap<>();
LauncherDiscoveryRequest request = toRequest(requestBuilder);
Launcher launcher = LauncherFactory.create();
launcher.execute(request, new TestExecutionListener() {
@Override
public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
results.put(testIdentifier, testExecutionResult);
}
});
return results;
}
use of org.junit.platform.launcher.Launcher in project tutorials by eugenp.
the class TestLauncher method main.
public static void main(String[] args) {
// @formatter:off
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(selectClass("com.baeldung.EmployeesTest")).configurationParameter("junit.conditions.deactivate", "com.baeldung.extensions.*").configurationParameter("junit.extensions.autodetection.enabled", "true").build();
// @formatter:on
TestPlan plan = LauncherFactory.create().discover(request);
Launcher launcher = LauncherFactory.create();
SummaryGeneratingListener summaryGeneratingListener = new SummaryGeneratingListener();
launcher.execute(request, new TestExecutionListener[] { summaryGeneratingListener });
launcher.execute(request);
summaryGeneratingListener.getSummary().printTo(new PrintWriter(System.out));
}
Aggregations