Generated banner for Quarkus Dev Services And Testing
Generated logo for Quarkus Dev Services And Testing

Quarkus Dev Services And Testing

GitHubOfficialFirst committed by jduboisDistributed by GitHub

  • Skill
  • Tool integration
  • Software development
  • MIT
  • No issues found

From the author

Quarkus Dev Services and testing: zero-config containers, @QuarkusTest, @QuarkusIntegrationTest, test resources, RestAssured, @InjectMock, profiles and continuous testing. Use when writing or fixing tests in a Quarkus project.
— the description by jdubois

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a comprehensive guide to testing Quarkus applications. It covers the use of Dev Services for automatic container management, the implementation of @QuarkusTest and @QuarkusIntegrationTest for various testing scopes, and the configuration of test resources. It also details mocking CDI beans, managing security contexts in tests, and utilizing continuous testing features to streamline the development feedback loop.

What it does

  • Configures zero-config containers for databases and messaging systems using Dev Services.
  • Implements unit and integration testing using @QuarkusTest and @QuarkusIntegrationTest.
  • Provides patterns for mocking CDI beans with @InjectMock.
  • Manages test security and transactional rollbacks for isolated test environments.
  • Facilitates custom test resource lifecycle management via QuarkusTestResourceLifecycleManager.
  • Enables continuous testing workflows within the Quarkus development mode.

When to use it

  • When setting up automated testing for a new or existing Quarkus project.
  • When you need to spin up infrastructure like PostgreSQL or Kafka automatically for tests.
  • When you need to mock internal application components to isolate test logic.
  • When troubleshooting test execution failures or integration test configuration in Maven.
  • When you want to optimize test execution speed by minimizing application restarts.

Advantages

  • Reduces boilerplate configuration by automating container lifecycle management.
  • Provides seamless integration with standard Java testing tools like JUnit 5 and RestAssured.
  • Supports both fast in-process testing and full-artifact integration testing.
  • Enables rapid development cycles through continuous testing and hot-reloading.
  • Offers granular control over test profiles and security contexts.

Usage examples

“How do I automatically start a PostgreSQL container for my Quarkus tests?”
The agent explains that by adding the Quarkus PostgreSQL extension, Dev Services will automatically start the container if no connection is configured, and shows how to enable it via properties.
“How can I mock a service bean in my Quarkus unit test?”
The agent provides an example using @InjectMock to replace a CDI bean with a mock object within a @QuarkusTest class.
“What is the command to run integration tests in a Quarkus project?”
The agent specifies using ./mvnw verify -DskipITs=false to ensure the Failsafe plugin executes the *IT classes.
“How do I enable continuous testing while developing?”
The agent instructs to run ./mvnw quarkus:dev and use the 'r' hotkey to start or re-run tests automatically on code changes.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/github/quarkus-dev-services-and-testing/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip quarkus-dev-services-and-testing.zip -d .agents/skills

Documentation by jdubois

Quarkus Dev Services and Testing

Check the project's Quarkus version first. Framework-neutral Testcontainers usage can use the optional java-testcontainers skill if installed (otherwise see https://java.testcontainers.org/); this skill covers only Quarkus-specific features.

Dev Services

In dev and test modes Quarkus starts containers (PostgreSQL, MySQL, Kafka, Redis, Keycloak, ...) automatically when the related extension is present and no connection is configured (Docker or Podman required).

# Global switch
quarkus.devservices.enabled=true
%dev.quarkus.datasource.devservices.image-name=postgres:17
# Reuse container across restarts (also requires testcontainers.reuse.enable=true in ~/.testcontainers.properties)
quarkus.datasource.devservices.reuse=true
# Fixed port (optional)
quarkus.datasource.devservices.port=5432
# Share between apps in dev mode
quarkus.kafka.devservices.shared=true

Disable one with quarkus.<ext>.devservices.enabled=false; configuring a URL/host explicitly also disables it. Dev UI (/q/dev-ui) lists running services.

Tests

@QuarkusTest
class GreetingResourceTest {
    @Test
    void hello() {
        given().when().get("/hello").then().statusCode(200).body(is("Hello"));
    }
}

Dependencies, test scope: io.quarkus:quarkus-junit (3.31+, what the 3.40 template generates) or quarkus-junit5 (3.27 template; still published and resolvable on 3.40) and io.rest-assured:rest-assured. Keep whichever the project already uses.

  • Inject beans in tests with @Inject; mock CDI beans with io.quarkus.test.InjectMock (quarkus-junit-mockito, formerly quarkus-junit5-mockito; verified mocking a PanacheRepository bean on 3.40.1).

  • Security: @TestSecurity(user="alice", roles="admin") (quarkus-test-security).

  • Profiles: @TestProfile(MyProfile.class) with QuarkusTestProfile#getConfigOverrides(); restarts the app, so use sparingly.

  • Transactions: @TestTransaction rolls back after the test.

  • @QuarkusIntegrationTest runs against the packaged artifact (jar, native binary or container); you cannot inject beans there, only call it over HTTP.

Test resources

public class WireMockResource implements QuarkusTestResourceLifecycleManager {
    public Map<String,String> start() { /* start, return config overrides */ return Map.of(); }
    public void stop() { }
}

@QuarkusTest
@WithTestResource(WireMockResource.class)   // io.quarkus.test.common.WithTestResource
class MyTest { }

@WithTestResource (verified on 3.40.1) applies to the annotated test class; Quarkus restarts the app when the set of resources changes. The older @QuarkusTestResource still compiles and runs on 3.40.1 but applies globally to all tests unless restrictToAnnotatedClass = true. Do not put @ConfigProperty injection points for resource-supplied values in a test class: test classes are scanned as beans, and the app fails to start for other test classes that lack the resource. Prefer Dev Services over custom resources when an extension supports it.

Running

./mvnw test                 # unit/@QuarkusTest
./mvnw verify -DskipITs=false  # also runs *IT via maven-failsafe-plugin

Gotcha: *IT classes (@QuarkusIntegrationTest) are run by Failsafe in the verify phase, and need the quarkus-maven-plugin build goal and the failsafe config (with java.util.logging.manager and maven.home system properties) generated by the project template. ./mvnw test silently skips them, and the 3.27 and 3.40 templates also set <skipITs>true</skipITs>, so plain ./mvnw verify skips them too (verified): pass -DskipITs=false (or -Dnative, whose profile flips it). With -Dnative and a container build on macOS or Windows, the binary is a Linux ELF and the IT fails with Exit code is: '126'; use a local Mandrel/GraalVM build for those.

Continuous testing: run ./mvnw quarkus:dev and press r to start or re-run tests and p to pause them (h lists the hotkeys); once running, tests re-run on code changes (quarkus.test.continuous-testing=enabled|paused|disabled).

Verified on Quarkus 3.40.1 (JDK 26, Docker Desktop): @QuarkusTest with Dev Services PostgreSQL (postgres:18 by default), @TestTransaction, @TestProfile, @TestSecurity, @InjectMock, *IT via Failsafe. @QuarkusTest and Dev Services on 3.27.6 as well.

Checklist

  • Use Dev Services before writing a custom resource.

  • Keep @QuarkusTest classes sharing the same profile/resources to avoid restarts.

  • Do not hard-code ports; RestAssured uses quarkus.http.test-port automatically.

See also: https://quarkus.io/guides/dev-services, https://quarkus.io/guides/getting-started-testing; for upgrades use quarkus update (https://quarkus.io/guides/update-quarkus).

Files

Requirements and compatibility

Written for: GitHub Copilot

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

First committed by
GitHub avatar of jduboisjdubois
Publisher
GitHub (Official)
Distributed by
GitHub
Source
github/awesome-copilot · skills/quarkus-dev-services-and-testing · commit 797337f
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Contributors
jdubois

AutoGineer is not affiliated with or endorsed by jdubois or GitHub.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download quarkus-dev-services-and-testing.zip