I have @QuarkusTest
based test class. And I want to implement a JUnit 5 extension (BeforeEachCallback, AfterEachCallback) that interacts with a specific bean of my Quarkus test context. I tried CDI.current()
, but that results into: java.lang.IllegalStateException: Unable to locate CDIProvide
In Spring based test for example I access the ApplicationContext via
@Override
public void beforeEach(final ExtensionContext extensionContext) {
final ApplicationContext applicationContext = SpringExtension.getApplicationContext(extensionContext);
MyBean myBean = applicationContext.getBean(MyBean.class);
}
which I can then use to programmatically query concrete beans from my test context. Is there any kind of similar approach to Quarkus tests? I mean, I can @Inject
the bean into my test class and access it in a @BeforeEach
method, but I am looking for a more 'reusable' solution.
Thank you very much.