Closed snowdrop-bot closed 3 years ago
@Nested classes are not working properly in @QuarkusTest.
@Nested
@QuarkusTest
@Nested tests run without throwing exception
Exception is thrown: java.lang.RuntimeException: Could not find method public void junit.NestedTest.GreetingResourceTest.beforeEach() on test class
java.lang.RuntimeException: Could not find method public void junit.NestedTest.GreetingResourceTest.beforeEach() on test class
Steps to reproduce the behavior:
mvn io.quarkus:quarkus-maven-plugin:1.13.7.Final:create -DprojectGroupId="junit.NestedTest" -DprojectArtifactId=NestedTest -DprojectVersion=1.0-SNAPSHOT
package junit.NestedTest; import io.quarkus.test.junit.QuarkusTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @QuarkusTest public class GreetingResourceTest { @BeforeEach public void beforeEach() { System.out.println("beforeEach"); } @Test public void test() { System.out.println("test"); } @Nested class Nested1 { @BeforeEach public void beforeEach() { System.out.println("beforeEach1"); } @Test public void test() { System.out.println("test1"); } @Nested class Nested2 { @BeforeEach public void beforeEach() { System.out.println("beforeEach2"); } @Test public void test() { System.out.println("test2"); } } } }
mvn test
uname -a
ver
Microsoft Windows [Version 10.0.18363.1500]
java -version
java version "1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot(TM) Client VM (build 25.201-b09, mixed mode)
1.13.7
mvnw --version
gradlew --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
https://github.com/quarkusio/quarkus/blob/645c35fcbf1c0a27ff782e39dbf8407ebbb818cd/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java#L949 This line skips the enclosing class of the nested class.
Reported also on stackoverflow: https://stackoverflow.com/questions/67932551/could-not-find-beforeeach-setup-method-on-nested-test-class-in-quarkustest/67986570#67986570
https://github.com/quarkusio/quarkus/issues/17975
$upstream:17975$
Describe the bug
@Nested
classes are not working properly in@QuarkusTest
.Expected behavior
@Nested
tests run without throwing exceptionActual behavior
Exception is thrown:
java.lang.RuntimeException: Could not find method public void junit.NestedTest.GreetingResourceTest.beforeEach() on test class
To Reproduce
Steps to reproduce the behavior:
mvn io.quarkus:quarkus-maven-plugin:1.13.7.Final:create -DprojectGroupId="junit.NestedTest" -DprojectArtifactId=NestedTest -DprojectVersion=1.0-SNAPSHOT
mvn test
Environment (please complete the following information):
Output of
uname -a
orver
Microsoft Windows [Version 10.0.18363.1500]
Output of
java -version
java version "1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot(TM) Client VM (build 25.201-b09, mixed mode)
GraalVM version (if different from Java)
Quarkus version or git rev
1.13.7
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Additional context
https://github.com/quarkusio/quarkus/blob/645c35fcbf1c0a27ff782e39dbf8407ebbb818cd/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java#L949 This line skips the enclosing class of the nested class.
Reported also on stackoverflow: https://stackoverflow.com/questions/67932551/could-not-find-beforeeach-setup-method-on-nested-test-class-in-quarkustest/67986570#67986570
https://github.com/quarkusio/quarkus/issues/17975
$upstream:17975$