snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

No (mock) injection when using @Nested JUnit tests #394

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

Describe the bug

Mock injection is not performed before execution of unit tests inside nested test classes.

Expected behavior

Attributes of the top level class annotated with @InjectMock are injected before the tests of @Nested test classes are executed.

Actual behavior

Attributes annotated with @InjectMock are null.

How to Reproduce?

A test like this fails because the service is not injected:

@QuarkusTest
class TestClass {
    @InjectMock
    private MyService service;

    @Nested
    class NestedTest {
        @Test
        void myTest() {
            assertNotNull(service);
        }
    }
}

And it passes if the nested class wrapper is removed.

Output of uname -a or ver

2.1.0.Final

Output of java -version

11

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

Maven

Additional information

No response


https://github.com/quarkusio/quarkus/issues/19391


$upstream:19391$