Skip to content
Advertisement

Could not find @BeforeEach setup() method on @Nested test class in @QuarkusTest

summary

On Junit Jupiter the Quarkus test extension seems to not find @BeforeEach setup methods for nested test classes and produces an error:

java.lang.RuntimeException: Could not find method void com.stackoverflow.examples.nestedtestwithquarkus.NestedTestWithQuarkus.setup() on test class

Is that a bug, a feature or am I missing something important?

edit 1: It seems like there’s an issue with nested tests in general. Some tests occasionally produce:

java.util.ServiceConfigurationError: org.testcontainers.dockerclient.DockerClientProviderStrategy: org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy not a subtype

I couldn’t yet reliably reproduce this one, though.


additional information

test class

JavaScript

pom.xml

JavaScript

full output

JavaScript

Advertisement

Answer

I have the same issue. I traced back the issue to this block of code https://github.com/quarkusio/quarkus/blob/645c35fcbf1c0a27ff782e39dbf8407ebbb818cd/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java#L928 c = c.getSuperclass(); skips your enclosing class NestedTestWithQuarkus.

I tried a quick hack with

JavaScript

but then I bumped into other problems, and adding another level of nesting introduced issues elsewhere in the code. I will raise a bug for this when I have some time. Until it gets fixed we will have to skip using the @Nested classes

Raised bug on Github https://github.com/quarkusio/quarkus/issues/17975

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement