question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@Nested (Junit5) associated with @QuarkusTest causes an UnsatisfiedResolutionException

See original GitHub issue

Description An UnsatisfiedResolutionException will be thrown when a test class is annotated with @QuarkusTest and implements inner test classes in connection with @Nested (Junit5).

Actual behavior The relevant dump of the stack trace (via mvn clean verify):

...
org.junit.jupiter.api.extension.TestInstantiationException: Failed to create test instance
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
Caused by: java.lang.reflect.InvocationTargetException
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: No bean found for required type [class org.acme.testcoverage.GreetingResourceTest$NestedTestClass] and qualifiers [[]]
...

Steps to reproduce the behavior

  1. Checkout https://github.com/quarkusio/quarkus-quickstarts/tree/master/tests-with-coverage-quickstart
  2. Adjust https://github.com/quarkusio/quarkus-quickstarts/blob/master/tests-with-coverage-quickstart/src/test/java/org/acme/testcoverage/GreetingResourceTest.java
package org.acme.testcoverage;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;

import java.util.UUID;

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
@Tag("integration")
public class GreetingResourceTest {

    @Nested
    class NestedTestClass {
        @Test
        public void testHelloEndpoint() {
            given()
                    .when().get("/hello")
                    .then()
                    .statusCode(200)
                    .body(is("hello"));
        }
    }

    @Test
    public void testGreetingEndpoint() {
        String uuid = UUID.randomUUID().toString();
        given()
                .pathParam("name", uuid)
                .when().get("/hello/greeting/{name}")
                .then()
                .statusCode(200)
                .body(is("hello " + uuid));
    }
}
  1. Execute mvn clean verify

Environment

  • Output of java -version:
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)
  • Output of mvnw --version:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 11.0.7, vendor: GraalVM Community, runtime: /Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.1.0/Contents/Home
...
  • Quarkus version: 1.6.1.Final

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
sapirgolancommented, Feb 10, 2021

Hi @stuartwdouglas ,

The issue still happen if the test class has multiple nested “Nested” classes. I’m using quarkus version 1.11.0-final

@QuarkusTest
@Tag("integration")
public class GreetingResourceTest {

    @Nested
    class NestedTestClass {

         @Nested
         class NestedDeeperTestClass {
         }
    }
}
2reactions
famodcommented, Aug 11, 2020

@sebitit Unfortunately, @Nested is (still) not supported. See #4393 for more details.

@stuartwdouglas In #4409 an explicit and descriptive exception was introduced for this case, but it was removed by the big classloader change: https://github.com/quarkusio/quarkus/commit/b67491c1ffe76248d5f01bc3e29be94c2cdd56a4#diff-985ca913dc620dcf2e54fd5e2b62a2bfL417 Do you remember why? Seems we should bringt it back…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find @BeforeEach setup() method on @Nested test ...
java - Could not find @BeforeEach setup() method on @Nested test class in @QuarkusTest - Stack Overflow. Stack Overflow for Teams – Start ......
Read more >
Testing Quarkus with Kotlin, JUnit and MockK | Novatec
To be honest – testing if Quarkus maps a RuntimeException to the status code 500 is obviously pretty useless. This example is vastly...
Read more >
quarkusio/quarkus 1.11.0.Final on GitHub - NewReleases.io
... HTTP Server does not support Expect: 100-continue; #11323 - @nested (Junit5) associated with @QuarkusTest causes an UnsatisfiedResolutionException.
Read more >
chore(deps): update dependency io.quarkus:quarkus ... - GitLab
... HTTP Server does not support Expect: 100-continue; #​11323 - @​Nested (Junit5) associated with @​QuarkusTest causes an UnsatisfiedResolutionException ...
Read more >
junit5 | 5th major version of the programmer-friendly testing
junit5 is a Java library typically used in Testing, Unit Testing applications. ... initTestState(QuarkusTestExtension.java:733) at io.quarkus.test.junit.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found