Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Nested not working in @QuarkusTest #17975

Closed
tomas-zuber opened this issue Jun 17, 2021 · 0 comments · Fixed by #17997
Closed

@Nested not working in @QuarkusTest #17975

tomas-zuber opened this issue Jun 17, 2021 · 0 comments · Fixed by #17997
Assignees
Labels
area/testing kind/bug Something isn't working
Milestone

Comments

@tomas-zuber
Copy link

tomas-zuber commented Jun 17, 2021

Describe the bug

@Nested classes are not working properly in @QuarkusTest.

Expected behavior

@Nested tests run without throwing exception

Actual 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:

  1. Run mvn io.quarkus:quarkus-maven-plugin:1.13.7.Final:create -DprojectGroupId="junit.NestedTest" -DprojectArtifactId=NestedTest -DprojectVersion=1.0-SNAPSHOT
  2. Add class
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");
            }
        }
    }
}
  1. Run mvn test

Environment (please complete the following information):

Output of uname -a or ver

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 or gradlew --version)

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

Additional context


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

@tomas-zuber tomas-zuber added the kind/bug Something isn't working label Jun 17, 2021
@quarkus-bot quarkus-bot bot added the env/windows Impacts Windows machines label Jun 17, 2021
@geoand geoand added area/testing and removed env/windows Impacts Windows machines labels Jun 17, 2021
@geoand geoand self-assigned this Jun 18, 2021
geoand added a commit to geoand/quarkus that referenced this issue Jun 18, 2021
stuartwdouglas added a commit that referenced this issue Jun 22, 2021
Ensure @QuarkusTest works with @nested and test lifecycle methods
@quarkus-bot quarkus-bot bot added this to the 2.1 - main milestone Jun 22, 2021
@gsmet gsmet modified the milestones: 2.1 - main, 2.0.0.Final Jun 22, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants