TestClassesFilter (String classFilterName) { String patterns = getTestPatterns(); if (!StringUtil.isEmpty(patterns)) { System.out.println("Using patterns: [" + patterns + "]"); return new PatternListTestClassFilter(StringUtil.split(patterns, ";")); } List<String> testGroupNames = getTestGroups(); if (testGroupNames.contains(ALL_TESTS_GROUP)) { System.out.println("Using all classes"); return TestClassesFilter.ALL_CLASSES; } List<URL> groupingFileUrls = Collections.emptyList(); if (!StringUtil.isEmpty(classFilterName)) { try { groupingFileUrls = Collections.list(getClassLoader().getResources(classFilterName)); } catch (IOException e) { e.printStackTrace(); } } List<URL> finalGroupingFileUrls = groupingFileUrls; TeamCityLogger.block("Loading test groups from ...", () -> { System.out.println("Loading test groups from: " + finalGroupingFileUrls); }); MultiMap<String, String> groups = MultiMap.createLinked(); for (URL fileUrl : groupingFileUrls) { try (InputStreamReader reader = new InputStreamReader(fileUrl.openStream(), StandardCharsets.UTF_8)) { GroupBasedTestClassFilter.readGroups(reader, groups); } catch (IOException e) { System.err.println("Failed to load test groups from " + fileUrl); e.printStackTrace(); } } System.out.println("Using test groups: " + testGroupNames); Set<String> testGroupNameSet = new HashSet<>(testGroupNames); testGroupNameSet.removeAll(groups.keySet()); testGroupNameSet.remove(GroupBasedTestClassFilter.ALL_EXCLUDE_DEFINED); if (!testGroupNameSet.isEmpty()) { System.err.println("Unknown test groups: " + testGroupNameSet); } return new GroupBasedTestClassFilter(groups, testGroupNames); }