use of org.apache.maven.surefire.testset.TestListResolver in project tycho by eclipse.
the class TestMojo method scanForTests.
protected ScanResult scanForTests() {
List<String> defaultIncludes = Arrays.asList("**/Test*.class", "**/*Test.class", "**/*TestCase.class");
List<String> defaultExcludes = Arrays.asList("**/*$*");
List<String> includeList;
List<String> excludeList;
if (test != null) {
String test = this.test;
test = test.replace('.', '/');
test = test.endsWith(".class") ? test : test + ".class";
test = test.startsWith("**/") ? test : "**/" + test;
includeList = Collections.singletonList(test);
} else if (testClass != null) {
includeList = Collections.singletonList(testClass.replace('.', '/') + ".class");
} else if (includes != null) {
includeList = includes;
includeList.removeAll(Collections.singleton(null));
} else {
includeList = defaultIncludes;
}
if (excludes != null) {
excludeList = excludes;
excludeList.removeAll(Collections.singleton(null));
} else {
excludeList = defaultExcludes;
}
// TODO bug 495353 we should we rather let TestListResolver do the work here
// by passing in the unparsed String or Strings instead of already parsed include/exclude list
// (this would add support for running single test methods, negation etc.)
TestListResolver resolver = new TestListResolver(includeList, excludeList);
DirectoryScanner scanner = new DirectoryScanner(testClassesDirectory, resolver);
DefaultScanResult scanResult = scanner.scan();
return scanResult;
}
use of org.apache.maven.surefire.testset.TestListResolver in project junit5 by junit-team.
the class JUnitPlatformProvider method getFilters.
private Filter<?>[] getFilters() {
List<Filter<?>> filters = new ArrayList<>();
Optional<List<String>> includes = getGroupsOrTags(getPropertiesList(INCLUDE_GROUPS), getPropertiesList(INCLUDE_TAGS));
includes.map(TagFilter::includeTags).ifPresent(filters::add);
Optional<List<String>> excludes = getGroupsOrTags(getPropertiesList(EXCLUDE_GROUPS), getPropertiesList(EXCLUDE_TAGS));
excludes.map(TagFilter::excludeTags).ifPresent(filters::add);
TestListResolver testListResolver = parameters.getTestRequest().getTestListResolver();
if (!testListResolver.isEmpty()) {
filters.add(new TestMethodFilter(testListResolver));
}
return filters.toArray(new Filter<?>[filters.size()]);
}
use of org.apache.maven.surefire.testset.TestListResolver in project junit5 by junit-team.
the class JUnitPlatformProviderTests method testExecutionOfMatchingTestMethods.
void testExecutionOfMatchingTestMethods(Class<?> testClass, String pattern, String... expectedTestNames) throws Exception {
TestListResolver testListResolver = new TestListResolver(pattern);
ProviderParameters providerParameters = providerParametersMock(testListResolver, testClass);
Launcher launcher = LauncherFactory.create();
JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters, launcher);
TestPlanSummaryListener executionListener = new TestPlanSummaryListener();
launcher.registerTestExecutionListeners(executionListener);
invokeProvider(provider, null);
assertEquals(1, executionListener.summaries.size());
TestExecutionSummary summary = executionListener.summaries.get(0);
int expectedCount = expectedTestNames.length;
assertEquals(expectedCount, summary.getTestsFoundCount());
assertEquals(expectedCount, summary.getTestsFailedCount());
assertEquals(expectedCount, summary.getFailures().size());
assertThat(failedTestDisplayNames(summary)).contains(expectedTestNames);
}
Aggregations