diff --git a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java index 3bf250b48b8e..ebf8f308ad36 100644 --- a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java +++ b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java @@ -29,6 +29,7 @@ import java.util.Set; import java.util.function.Function; import java.util.function.Predicate; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.apiguardian.api.API; @@ -103,6 +104,28 @@ private static void registerAutoDetectedExtensions(MutableExtensionRegistry exte ClassLoaderUtils.getDefaultClassLoader()); ServiceLoaderUtils.filter(serviceLoader, filter) // .forEach(extensionRegistry::registerAutoDetectedExtension); + + logExcludedExtensions(serviceLoader, filter); + } + + private static void logExcludedExtensions(ServiceLoader serviceLoader, + Predicate> filter) { + List> excludeExtensions = new ArrayList<>(); + serviceLoader.forEach(extension -> { + if (!filter.test(extension.getClass())) { + excludeExtensions.add(extension.getClass()); + } + }); + + if (!excludeExtensions.isEmpty()) { + // @formatter:off + List excludeExtensionNames = excludeExtensions + .stream() + .map(Class::getName) + .collect(Collectors.toList()); + // @formatter:on + logger.config(() -> String.format("Excluded auto-detected extensions: %s", excludeExtensionNames)); + } } /**