mercredi 10 février 2021

Quarkus does not @Inject beans in @QuarkusTest suite

I am pretty new in Quarkus but I'm pretty proficient in other IoC frameworks (Spring). I have a bean declared as follow

@ApplicationScoped
public class TestingRepo {
    public String greet() {
        return "Hi";
    }
}

and I do also have a Quarkus test that looks like this

@QuarkusTest
public class InjectionTest {

    @Inject
    public TestingRepo tr;

    @Test
    public void testInjection() {
        Assertions.assertNotNull(tr);
    }
}

When I do mvn test I got:

[ERROR] testInjection  Time elapsed: 0.006 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: not <null>
     at org.mytest.InjectionTest.testInjection(InjectionTest.java:25)

There is something I'm missing? I'm expecting to have the bean injected and not being null! Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire