We have a Quarkus+vertx application (written on java) and we want to test a few specific services from it, specifically classes annotated with
@ApplicationScoped
@Startup
There is MainService
class and there are some other SecondaryService
classes which implement specific Secondary
interface. Each of these SecondaryService
classes have a @Postconstruct
method that puts the service in a map which is used in MainService
and makes a request to fetch some data.
I don’t want to start Quarkus application with all of its context as there are a lot of other services and verticles that we don’t need for this test.
So i am looking for a way to inject only MainService
and all of SecondaryService
(more precice all classes that implement Secondary
interface)
Because i don’t want all Quarkus with all its context to start, i am not using @QuarkusTest
annotation. I tried to use @QuarkusComponentTest
and inject services as follows
@Inject
MainService mainService;
@Inject
List<Secondary> secondaryServices;
But seems that services are not injected. I don’t get to init
or @PostConstruct
of any of these services.
Also the amount of implementations of Secondary
is changing. Sometimes we add new ones and sometimes we remove some so injecting them one by one is not a robust option.
is there a way when testing quarkus to inject only specific services without starting the whole application?
2