From ea55d14742934ab38c48825cd1939cc20158d0dd Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Tue, 25 Jan 2022 12:35:30 +1100 Subject: [PATCH] Handle @Nested with continuous testing Fixes #23075 (cherry picked from commit a464e10ca9507ae3cff5a82c6052761b837dd834) --- .../dev/testing/JunitTestRunner.java | 22 ++++++++++++++++++- .../src/main/resources/tls/README.md | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java index 083bd08a0ec76..3d2664199d917 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java @@ -35,6 +35,7 @@ import org.jboss.jandex.Index; import org.jboss.jandex.Indexer; import org.jboss.logging.Logger; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Tags; @@ -90,6 +91,7 @@ public class JunitTestRunner { public static final DotName TEST_FACTORY = DotName.createSimple(TestFactory.class.getName()); public static final DotName TEST_TEMPLATE = DotName.createSimple(TestTemplate.class.getName()); public static final DotName TESTABLE = DotName.createSimple(Testable.class.getName()); + public static final DotName NESTED = DotName.createSimple(Nested.class.getName()); private final long runId; private final DevModeContext.ModuleInfo moduleInfo; private final DevModeContext devModeContext; @@ -542,10 +544,18 @@ private DiscoveryResult discoverTestClasses() { } Set allTestAnnotations = collectTestAnnotations(index); Set allTestClasses = new HashSet<>(); + Map enclosingClasses = new HashMap<>(); for (DotName annotation : allTestAnnotations) { for (AnnotationInstance instance : index.getAnnotations(annotation)) { if (instance.target().kind() == AnnotationTarget.Kind.METHOD) { - allTestClasses.add(instance.target().asMethod().declaringClass().name()); + ClassInfo classInfo = instance.target().asMethod().declaringClass(); + allTestClasses.add(classInfo.name()); + if (classInfo.classAnnotation(NESTED) != null) { + var enclosing = classInfo.enclosingClass(); + if (enclosing != null) { + enclosingClasses.put(classInfo.name(), enclosing); + } + } } } } @@ -557,6 +567,16 @@ private DiscoveryResult discoverTestClasses() { if (integrationTestClasses.contains(name) || quarkusTestClasses.contains(name)) { continue; } + var enclosing = enclosingClasses.get(testClass); + if (enclosing != null) { + if (integrationTestClasses.contains(enclosing.toString())) { + integrationTestClasses.add(name); + continue; + } else if (quarkusTestClasses.contains(enclosing.toString())) { + quarkusTestClasses.add(name); + continue; + } + } ClassInfo clazz = index.getClassByName(testClass); if (Modifier.isAbstract(clazz.flags())) { continue; diff --git a/integration-tests/grpc-mutual-auth/src/main/resources/tls/README.md b/integration-tests/grpc-mutual-auth/src/main/resources/tls/README.md index 4a1df9e124dc8..87d29962a73c7 100644 --- a/integration-tests/grpc-mutual-auth/src/main/resources/tls/README.md +++ b/integration-tests/grpc-mutual-auth/src/main/resources/tls/README.md @@ -8,6 +8,7 @@ openssl req -x509 -new -newkey rsa:2048 -nodes -keyout ca.key -out ca.pem \ -config ca-openssl.cnf -days 3650 -extensions v3_req ``` + When prompted for certificate information, everything is default. Client is issued by CA: