quarkus-dev-services-and-testing
Fungsinya
Alat ini membantu Anda menguji kode Quarkus secara otomatis. Alat ini menjalankan database dan layanan lain yang diperlukan untuk pengujian tanpa memerlukan konfigurasi manual.
Kapan dipakai
- ✓Ketika menulis tes untuk proyek Quarkus Anda.
- ✓Ketika Anda perlu mensimulasikan database untuk sebuah tes.
- ✓Ketika memperbaiki bug pada tes yang sudah ada.
Link skill
https://github.com/github/awesome-copilot/blob/main/skills/quarkus-dev-services-and-testing/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
“Saya ingin menguji API pengguna saya dengan database PostgreSQL.”
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Saat Anda menjalankan tes, Quarkus memeriksa apakah diperlukan layanan seperti database. Jika ya, dan tidak ditemukan database yang sudah dikonfigurasi, Quarkus secara otomatis menjalankannya menggunakan Docker. Dengan begitu, tes Anda memiliki lingkungan yang dibutuhkan untuk berjalan.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
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 withio.quarkus.test.InjectMock(quarkus-junit-mockito, formerlyquarkus-junit5-mockito; verified mocking aPanacheRepositorybean on 3.40.1). - Security:
@TestSecurity(user="alice", roles="admin")(quarkus-test-security). - Profiles:
@TestProfile(MyProfile.class)withQuarkusTestProfile#getConfigOverrides(); restarts the app, so use sparingly. - Transactions:
@TestTransactionrolls back after the test. @QuarkusIntegrationTestruns 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.
…
Pertanyaan umum
Apakah saya perlu menginstal sesuatu tambahan?
Anda perlu menginstal dan menjalankan Docker atau Podman di komputer Anda agar layanan dapat berjalan otomatis.
Bagaimana cara menonaktifkan fitur ini?
Anda dapat menonaktifkan layanan otomatis untuk jenis layanan tertentu (seperti database) atau untuk semua layanan dengan mengubah pengaturan Quarkus.
Bisakah saya menggunakan ini dengan jenis tes lainnya?
Bisa, alat ini berfokus pada tes dalam ekosistem Quarkus, sehingga mudah diintegrasikan dengan fitur khusus framework tersebut.
Detail
Deskripsi asli dari pembuat
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.
repo: github/awesome-copilot
Popularitas
- Bintang GitHub
- 40k
- Peringkat
- #7378
- Lisensi
- MIT
- Diperbarui
- 15/10/2026
Komentar
- …
Skill lain dari repositori ini
acquire-codebase-knowledge
40kMembantu agent Anda memahami dan mendokumentasikan proyek kode yang sudah ada. Berguna untuk proses onboarding anggota baru atau mendapatkan gambaran arsitektur.
acreadiness-assess
40kMemungkinkan agent Anda menilai kesiapan proyek untuk AI dan membuat laporannya. Berguna untuk mengetahui seberapa siap proyek menggunakan alat AI.
acreadiness-generate-instructions
40kMembantu agent Anda membuat instruksi untuk alat AI berdasarkan hasil penilaian. Berguna untuk meningkatkan cara AI berinteraksi dengan kode dan menutup celah yang ditemukan.
acreadiness-policy
40kMemungkinkan agent Anda membantu menyusun atau menerapkan kebijakan untuk penilaian proyek AI. Berguna untuk menstandarisasi evaluasi proyek dan memastikan kepatuhan.
Skill serupa
test-driven-development
311kMengajari agent Anda menulis tes yang gagal dulu, melihatnya gagal, lalu menulis kode terkecil yang lulus, sebelum membangun fitur atau perbaikan apa pun.
verification-before-completion
311kMengajari agent Anda menjalankan pemeriksaan nyata dan membaca keluarannya sebelum menyatakan tugas, perbaikan, atau build sudah selesai atau lulus.
migrate-to-shoehorn
310kMengganti type cast berisiko di file tes Anda dengan pustaka shoehorn, sehingga tes bisa memakai data parsial dan tetap lulus pemeriksaan tipe.