Skip to content

Commit

Permalink
Proper log of integration test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
seregamorph committed Dec 6, 2024
1 parent e944d55 commit e2ce9bf
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ public <T> List<List<Class<?>>> sort(List<T> testItems, TestClassExtractor<T> te
testClasses.classes.add(itClass);
classToOrder.put(itClass, testClasses.order);
}
if (!configToTests.isEmpty()) {
printSuiteTestsPerConfig(configToTests);
}

testItems.sort(comparing(testItem -> {
Class<?> realClass = testClassExtractor.getTestClass(testItem);
Expand All @@ -107,11 +104,17 @@ public <T> List<List<Class<?>>> sort(List<T> testItems, TestClassExtractor<T> te
}
}));

return configToTests.values().stream()
List<List<Class<?>>> sortedConfigToTests = configToTests.values().stream()
.map(testClasses -> testClasses.classes.stream()
.sorted(comparing(testItem -> isDirtiesContextAfterClass(testItem) ? 1 : 0))
.collect(Collectors.toList()))
.collect(Collectors.toList());

if (!sortedConfigToTests.isEmpty()) {
printSuiteTestsPerConfig(sortedConfigToTests);
}

return sortedConfigToTests;
}

private <T> Set<Class<?>> filterAndLogItClasses(List<T> testItems, TestClassExtractor<T> testClassExtractor) {
Expand Down Expand Up @@ -214,14 +217,14 @@ private void printSuiteTests(int totalTests, Collection<Class<?>> itClasses) {
log.info(sw.toString());
}

private void printSuiteTestsPerConfig(Map<MergedContextConfiguration, TestClasses> configToTests) {
private void printSuiteTestsPerConfig(List<List<Class<?>>> sortedConfigToTests) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
pw.println("Integration test classes grouped and reordered by MergedContextConfiguration " +
"(" + configToTests.size() + " groups):");
"(" + sortedConfigToTests.size() + " groups):");
pw.println("------");
configToTests.values().forEach(itClasses -> {
for (Class<?> itClass : itClasses.classes) {
sortedConfigToTests.forEach(itClasses -> {
for (Class<?> itClass : itClasses) {
pw.println(itClass.getName());
}
pw.println("------");
Expand Down

0 comments on commit e2ce9bf

Please sign in to comment.