use of org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder in project gradle by gradle.
the class JUnitPlatformTestClassProcessor method createLauncherDiscoveryRequest.
private LauncherDiscoveryRequest createLauncherDiscoveryRequest(List<Class<?>> testClasses) {
List<DiscoverySelector> classSelectors = testClasses.stream().map(DiscoverySelectors::selectClass).collect(Collectors.toList());
LauncherDiscoveryRequestBuilder requestBuilder = LauncherDiscoveryRequestBuilder.request().selectors(classSelectors);
addTestNameFilters(requestBuilder);
addEnginesFilter(requestBuilder);
addTagsFilter(requestBuilder);
return requestBuilder.build();
}
use of org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder in project ant by apache.
the class SingleTestClass method createTestRequests.
@Override
List<TestRequest> createTestRequests(final JUnitLauncherTask launcherTask) {
final Project project = launcherTask.getProject();
if (!shouldRun(project)) {
launcherTask.log("Excluding test " + this.testClass + " since it's considered not to run " + "in context of project " + project, Project.MSG_DEBUG);
return Collections.emptyList();
}
final LauncherDiscoveryRequestBuilder requestBuilder = LauncherDiscoveryRequestBuilder.request();
if (!this.hasMethodsSpecified()) {
requestBuilder.selectors(DiscoverySelectors.selectClass(this.testClass));
} else {
// add specific methods
final String[] methods = this.getMethods();
for (final String method : methods) {
requestBuilder.selectors(DiscoverySelectors.selectMethod(this.testClass, method));
}
}
// add any engine filters
final String[] enginesToInclude = this.getIncludeEngines();
if (enginesToInclude != null && enginesToInclude.length > 0) {
requestBuilder.filters(EngineFilter.includeEngines(enginesToInclude));
}
final String[] enginesToExclude = this.getExcludeEngines();
if (enginesToExclude != null && enginesToExclude.length > 0) {
requestBuilder.filters(EngineFilter.excludeEngines(enginesToExclude));
}
return Collections.singletonList(new TestRequest(this, requestBuilder));
}
use of org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method removesCompleteClassIfItHasExcludedTag.
@Test
void removesCompleteClassIfItHasExcludedTag() {
Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(excludeTags(Categories.Plain.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.core.LauncherDiscoveryRequestBuilder in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesOnlyNotExcludedTaggedMethodOfNestedTestClass.
@Test
void executesOnlyNotExcludedTaggedMethodOfNestedTestClass() {
Class<?> testClass = EnclosedJUnit4TestCase.class;
Class<?> nestedTestClass = EnclosedJUnit4TestCase.NestedClass.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(excludeTags(Categories.Failing.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", testClass.getName(), nestedTestClass.getName(), "successfulTest");
}
use of org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method removesCompleteClassIfNoMethodHasMatchingTags.
@Test
void removesCompleteClassIfNoMethodHasMatchingTags() {
Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(includeTags("wrong-tag"));
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