liveBook · Manning

Test

As explained in Quarkus in Action

A test is an automated or manual evaluation of software behavior against expected results.

Testing evaluates Quarkus application behavior against expected results while fitting into continuous development, JVM execution, native builds, and packaged applications. Quarkus integrates testing with JUnit 5 and can manage supporting services such as databases and message brokers through Dev Services. section 5.0 section 3.6

Quarkus testing supports several execution and isolation strategies:

  • Run tests in the JVM with the application and test logic in a single process. section 2.2.2
  • Run integration tests against packaged artifacts, including executable JARs, native images, or containers, with the test JVM separate from the application. section 2.2.2 section 5.6
  • Group tests with testing profiles so each group can use a separate application instance and configuration. section 5.0
  • Replace CDI beans or define behavior with Mockito when remote or otherwise unsuitable collaborators should not run directly. section 5.0 section 5.6

Testing an HTTP endpoint

A JUnit test annotated with @QuarkusTest can call /hello through REST Assured and assert both the HTTP status and response body. A matching @QuarkusIntegrationTest can extend that test class to execute the same checks against the packaged application. section 2.2.2

Listing 2.5 Quarkus test example with REST Assured
package org.acme;

import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;

@QuarkusTest
public class GreetingResourceTest {

    @Test
    public void testHelloEndpoint() {
        given()
          .when().get("/hello")
          .then()
             .statusCode(200)                      #1
             .body(is("Hello from Quarkus REST"));    #2
    }
}

Inspect a complete Quarkus and REST Assured test that verifies an endpoint response. section 2.2.2

How Quarkus in Action covers it

How deep it goes
Covers JUnit integration, execution modes, profiles, mocks, and endpoint assertions, but defers exhaustive test design guidance.
Examples
Demonstrates endpoint assertions, packaged-mode reuse, extension metadata checks, configuration overrides, and automatically managed test services.
What it assumes
Assumes Java application testing familiarity while introducing Quarkus-specific execution modes, profiles, mocks, and Dev Services.
What you can do after
Apply it via JUnit, REST Assured, Mockito, testing profiles, and Quarkus integration-test annotations.
How it connects
Connects JUnit 5, REST Assured, Mockito, CDI, testing profiles, Dev Services, native images, and integration testing.

Also explained in

Compare how 53 books explain test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.