Java / Quarkus Interview questions
How do you write integration tests in Quarkus using @QuarkusTest?
@QuarkusTest is the core annotation for writing tests that run against a real, started instance of the Quarkus application — CDI container active, extensions initialized — rather than mocking the framework away, which is what makes these true integration tests instead of isolated unit tests.
@QuarkusTest class GreetingResourceTest { @Test void testHelloEndpoint() { given() .when().get("/hello") .then() .statusCode(200) .body(is("Hello, Quarkus!")); } }
Under the hood, @QuarkusTest starts the application once for the whole test class (reusing that started instance across test methods for speed), and commonly pairs with REST-assured (as in the example above) for exercising HTTP endpoints, or with regular @Inject to pull in CDI beans directly for lower-level component tests.
Because the test framework is also aware of Quarkus's continuous testing feature, tests annotated with @QuarkusTest automatically re-run in the background during Dev Mode whenever related source or test code changes, giving near-instant feedback without manually re-triggering the test suite.
More Related questions...
