Kiran K
Kiran K

Reputation: 768

Quarkus : Wait for business init logic to run before starting Integration Test

I have an application whose init requires some business logic to run. This has been implemented via implementing a io.quarkus.runtime.QuarkusApplication whose run() method initialises the application.

My problem is that when writing a @QuarkusIntegrationTest I have a @BeforeAll method which does the test data setup and this test data setup needs to be executed after the init logic in the io.quarkus.runtime.QuarkusApplication has completed.

Is there any way to enforce this ?

Upvotes: 0

Views: 726

Answers (1)

Rok T.
Rok T.

Reputation: 409

If I understand correctly I think you can solve your issue with the @QuarkusTestResource annotation. I use this with @QuarkusTest tests, but I think it should work with the @QuarkusIntegrationTest as well

Implement the QuarkusTestResourceLifecycleManager interface in the class where you have your prerequisite business logic (e.g. TestResource.class) and then annotate your test class with @QuarkusTestResource(value = TestResource.class).

This will initialize your test resource before the Quarkus runtime starts. You could then also inject the test resource into your test class for interaction with the more here: https://quarkus.io/guides/getting-started-testing#quarkus-test-resource

Upvotes: 1

Related Questions