diff --git a/test-framework/junit/src/main/java/io/quarkus/test/junit/launcher/CustomLauncherInterceptor.java b/test-framework/junit/src/main/java/io/quarkus/test/junit/launcher/CustomLauncherInterceptor.java index 319c979717449..8b03396bb9eb4 100644 --- a/test-framework/junit/src/main/java/io/quarkus/test/junit/launcher/CustomLauncherInterceptor.java +++ b/test-framework/junit/src/main/java/io/quarkus/test/junit/launcher/CustomLauncherInterceptor.java @@ -124,7 +124,7 @@ public void launcherDiscoveryFinished(LauncherDiscoveryRequest request) { // On the other hand, if the QuarkusTestExtension is registered by a service loader mechanism, it gets loaded after the discovery phase finishes, // so needs the TCCL to still be the facade classloader. // This compromise does mean you can't use the service loader mechanism to avoid having to use `@QuarkusTest` and also use Quarkus config in your own test extensions, but that combination is very unlikely. - if (!facadeLoader.isServiceLoaderMechanism()) { + if (facadeLoader != null && !facadeLoader.isServiceLoaderMechanism()) { // Do not close the facade loader at this stage, because discovery finished may be called several times within a single run // Ideally we would reset to what the TCCL was when we started discovery, but we can't, // because the intercept method will have set something before the discovery start is triggered. @@ -138,7 +138,7 @@ public void launcherDiscoveryFinished(LauncherDiscoveryRequest request) { if (orderer.isEmpty() || !(orderer.get() .equals(DESIRED_CLASS_ORDERER.getName()) || orderer.get().equals(CONFIG_SETTING_DESIRED_CLASS_ORDERER.getName()))) { - if (facadeLoader.hasMultipleClassLoaders()) { + if (facadeLoader != null && facadeLoader.hasMultipleClassLoaders()) { String message = getFailureMessageForJUnitMisconfiguration(orderer); throw new IllegalStateException(message); } @@ -157,7 +157,7 @@ private static String getFailureMessageForJUnitMisconfiguration(Optional String message; if (orderer.isPresent()) { message = String.format( - "%sTo set a test order while preserving the Quarkus required sorting, please set use the Quarkus configuration to set junit.quarkus.orderer.secondary-orderer=%s, and remove the junit-platform.properties (if any) from the classpath.", + "%sTo set a test order while preserving the Quarkus required sorting, please use the Quarkus configuration to set junit.quarkus.orderer.secondary-orderer=%s, and remove the junit-platform.properties (if any) from the classpath.", generalExplanation, orderer.get()); } else { message = String.format(