diff --git a/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusUnitTest.java b/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusUnitTest.java index 8d28ccae9e6d3..463cc04bb00c6 100644 --- a/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusUnitTest.java +++ b/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusUnitTest.java @@ -572,8 +572,9 @@ private Throwable unwrapException(Throwable cause) { public void afterAll(ExtensionContext extensionContext) throws Exception { actualTestClass = null; actualTestInstance = null; + List records = null; if (assertLogRecords != null) { - assertLogRecords.accept(inMemoryLogHandler.records); + records = new ArrayList<>(inMemoryLogHandler.records); } rootLogger.setHandlers(originalHandlers); inMemoryLogHandler.clearRecords(); @@ -606,9 +607,12 @@ public void afterAll(ExtensionContext extensionContext) throws Exception { if (afterAllCustomizer != null) { afterAllCustomizer.run(); } + ClearCache.clearAnnotationCache(); + GroovyCacheCleaner.clearGroovyCache(); + } + if (records != null) { + assertLogRecords.accept(records); } - ClearCache.clearAnnotationCache(); - GroovyCacheCleaner.clearGroovyCache(); } @Override