In Quarkus testing, one can easily use beans by annotating them with @Inject:
package com.test;
@QuarkusTest
class InjectionTest {
@Inject
SomeBean someBean;
@Test
void someTest() {
// Testing logic, assertions and all
}
The "SomeBean":
package com.test;
@ApplicationScoped
public class SomeBean {
}
Unfortunately this results in an error when using a multiple modular setup. An example project for such a setup can be found here: https://github.com/lssoares/multi-maven-quarkus To reproduce, just try to inject any bean into any of the tests.
The error thrown will look something like this:
Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type com.test.SomeBean and qualifiers [@Default]
- java member: com.test.InjectionTest#someBean
The injection of this bean goes perfectly well when I run the application. Why does Quarkus have the bean in normal context, but not in test context? Why does this problem specifically occur in a multi-modular setup? And more importantly, how to fix this?