use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method filtersOutAllDescendantsOfParameterizedTestCase.
@Test
void filtersOutAllDescendantsOfParameterizedTestCase() {
Class<?> testClass = ParameterizedTestCase.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters((PostDiscoveryFilter) descriptor -> excluded("excluded"));
TestPlan testPlan = discover(request);
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).isEmpty();
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactly("JUnit Vintage");
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesOnlyTaggedMethodOfRegularTestClass.
@Test
void executesOnlyTaggedMethodOfRegularTestClass() {
Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(includeTags(Categories.Failing.class.getName()));
TestPlan testPlan = discover(request);
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).hasSize(2);
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactlyInAnyOrder("JUnit Vintage", testClass.getName(), "failingTest");
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesOnlyTaggedMethodsForSuite.
@Test
void executesOnlyTaggedMethodsForSuite() {
Class<?> suiteClass = JUnit4SuiteWithTwoTestCases.class;
Class<?> testClass = PlainJUnit4TestCaseWithTwoTestMethods.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(suiteClass)).filters(includeTags(Categories.Successful.class.getName()));
TestPlan testPlan = discover(request);
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).hasSize(3);
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactlyInAnyOrder("JUnit Vintage", suiteClass.getName(), testClass.getName(), "successfulTest");
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method removesCompleteClassWithNotFilterableRunnerIfItHasExcludedTag.
@Test
void removesCompleteClassWithNotFilterableRunnerIfItHasExcludedTag() {
Class<?> testClass = JUnit4TestCaseWithNotFilterableRunner.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(excludeTags(Categories.Successful.class.getName()));
TestPlan testPlan = discover(request);
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).isEmpty();
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactly("JUnit Vintage");
}
use of org.junit.platform.launcher.TestPlan 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