use of org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesAllTestsForNotFilterableChildRunnerOfSuite.
@TrackLogRecords
@Test
void executesAllTestsForNotFilterableChildRunnerOfSuite(LogRecordListener logRecordListener) {
Class<?> suiteClass = JUnit4SuiteOfSuiteWithFilterableChildRunner.class;
Class<?> testClass = JUnit4TestCaseWithNotFilterableRunner.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(suiteClass)).filters((PostDiscoveryFilter) descriptor -> includedIf(descriptor.getDisplayName().contains("#1")));
TestPlan testPlan = discover(request);
logRecordListener.clear();
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).hasSize(4);
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactlyInAnyOrder("JUnit Vintage", suiteClass.getName(), testClass.getName(), "Test #0", "Test #1");
//
assertThat(logRecordListener.stream(RunnerTestDescriptor.class, Level.WARNING).map(LogRecord::getMessage)).containsExactly(//
"Runner " + Suite.class.getName() + " (used on class " + suiteClass.getName() + ")" + " was not able to satisfy all filter requests.");
}
use of org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder 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.core.LauncherDiscoveryRequestBuilder 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.core.LauncherDiscoveryRequestBuilder 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.core.LauncherDiscoveryRequestBuilder 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");
}
Aggregations