testing-patterns
Skill7 starsChanged 21 days agoApache-2.0View on GitHub
Testing patterns for Quarkus - @QuarkusTest, RestAssured, Mockito mocking, Dev Services (built-in Testcontainers), and @QuarkusIntegrationTest. Use when user asks about testing, writing tests, test coverage, or test failures.
44 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- xsovad06/sovatheir own version, first seen Nov 8, 2026
- gopalparashar421/agent-skillstheir own version, first seen Nov 8, 2026
- soilmass/motion-design-agenttheir own version, first seen Nov 8, 2026
- seandkendall/kiro-configtheir own version, first seen Nov 1, 2026
- svngoku/coding-agents-skillstheir own version, first seen Nov 1, 2026
- piomin/claude-ai-spring-bootedited, first seen Oct 25, 2026
Used with
Projects with it also use intelligent-routing, bash-linux and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SKB3002Skillintelligent-routing
Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.
Also in 5 projects that use this
xenitV1Skillbash-linux
Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.
Also in 6 projects that use this
xenitV1Skillred-team-tactics
Red team tactics principles based on MITRE ATT&CK. Attack phases, detection evasion, reporting.
Also in 6 projects that use this
ChrisWilesSkillformik-patterns
Formik form handling with validation patterns. Use when building forms, implementing validation, or handling form submission.
Also in 3 projects that use this
SKB3002Skillnextjs-react-expert
React and Next.js performance optimization from Vercel Engineering. Use when building React components, optimizing performance, eliminating waterfalls, reducing bundle size, reviewing code for performance issues, or implementing server/client-side optimizations.
Also in 3 projects that use this
adybaSkillsafe-workflow
SAFe Agentic Workflow orchestrator. Teaches the full SAFe methodology adapted for AI agents: pattern discovery, exit states, quality gates, agent personas, and specs-driven development. Use when setting up a project with SAFe workflow, understanding the multi-agent methodology, or coordinating work across agent personas. Triggers: "SAFe workflow", "agent workflow", "safe harness", "specs-driven", "exit states", "quality gates", "multi-agent workflow".
Also in 3 projects that use this
- +4 more from xenitV1
Other versions44 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- piomin/claude-ai-spring-boot★ 1.4k23% same
Wrote their own version · 43
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- ChrisWiles/claude-code-showcase★ 6.1ksame name
- ag2ai/faststream★ 5.4ksame name
- bybren-llc/safe-agentic-workflow★ 405same name
- dilolabs/nosia★ 211same name
- xenitV1/Antigravity-Workflows★ 130same name
- langchain-ai/skills-benchmarks★ 116same name
- leather-io/mono★ 28same name
- VoDaiLocz/kilo-kit-mcp★ 28same name
33 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- code-qualitySkill
- design-patternsSkill
- java-modernSkill
- jpa-patternsSkill
- logging-patternsSkill
- quarkusSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 29 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Test failures or debugging test issues
- Distinctive: line 57
Use these for classes with no CDI dependencies, or where you want to mock collaborators manually without booting Quarkus at all.
- Very specific: line 295
Add the extension for the service you need — no quarkus.datasource.jdbc.url, no container declaration, nothing else:
- Distinctive: line 428
Run native-image verification in CI with:
- Very specific: line 440
Use a QuarkusTestProfile to run the same test class with different config, enabled alternatives, or test resources.
“Common” is measured: kept by at least 6 in 10 of the 29 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Testing Patterns Skill
Testing strategies for Quarkus applications. Always write both positive and negative test cases.
When to Use
- "write tests" / "add test coverage" / "test this"
- Test failures or debugging test issues
- Choosing between plain unit tests,
@QuarkusTest, and@QuarkusIntegrationTest - Setting up a database/Kafka/etc. for tests
Test Types Overview
Quarkus has three test levels, with no separate "slice" annotations needed per layer:
| Level | How | Speed | Scope | When to Use |
| Plain unit test | No Quarkus annotation, @ExtendWith(MockitoExtension.class) | Fastest | Single class, no CDI | Pure business logic with no injected beans |
@QuarkusTest | Boots the full CDI container in the test JVM | Fast (app stays up across the test run) | Whole app, in-process | REST endpoints, CDI beans, repositories — the default choice |
@QuarkusIntegrationTest | Starts the built artifact (jar / native image / container) as a separate process | Slowest | End-to-end against the real packaged app | Verifying the artifact that actually ships, incl. native image |
Dependencies
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<!-- Only needed for @InjectMock / @InjectSpy -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>quarkus-junit5 provides @QuarkusTest. RestAssured automatically targets the right test port — no base URL configuration needed.
Plain Unit Tests (Business Logic)
Use these for classes with no CDI dependencies, or where you want to mock collaborators manually without booting Quarkus at all.
@ExtendWith(MockitoExtension.class)
class OrderServiceTest {
@Mock
private OrderRepository orderRepository;
@Mock
private ProductService productService;
@InjectMocks
private OrderService orderService;
// ✅ Positive test
@Test
@DisplayName("Should create order with valid items")
void shouldCreateOrder() {
// Given
var request = new OrderRequest(List.of(new OrderItem(1L, 2)));
var product = new Product();
product.setId(1L);
product.setPrice(new BigDecimal("10.00"));
when(productService.findById(1L)).thenReturn(product);
// When
Order result = orderService.create(request);
// Then
assertThat(result).isNotNull();
verify(orderRepository).persist(any(Order.class));
}
// ✅ Negative test
@Test
@DisplayName("Should throw when product not found")
void shouldThrowWhenProductNotFound() {
var request = new OrderRequest(List.of(new OrderItem(999L, 1)));
when(productService.findById(999L))
.thenThrow(new EntityNotFoundException("Product not found"));
assertThatThrownBy(() -> orderService.create(request))
.isInstanceOf(EntityNotFoundException.class)
.hasMessageContaining("Product not found");
verify(orderRepository, never()).persist(any(Order.class));
}
}REST API Tests with @QuarkusTest + RestAssured
@QuarkusTest
class ProductResourceTest {
// ✅ Positive - successful creation
@Test
@DisplayName("POST /api/v1/products - returns 201")
void createProduct_validRequest_returns201() {
given()
.contentType(ContentType.JSON)
.body("""
{"name": "Widget", "price": 10.00}
""")
.when().post("/api/v1/products")
.then()
.statusCode(201)
.body("name", is("Widget"));
}
// ✅ Negative - validation failure
@Test
@DisplayName("POST /api/v1/products - blank name returns 400")
void createProduct_blankName_returns400() {
given()
.contentType(ContentType.JSON)
.body("""
{"name": "", "price": 10.00}
""")
.when().post("/api/v1/products")
.then()
.statusCode(400);
}
// ✅ Negative - not found
@Test
@DisplayName("GET /api/v1/products/999 - returns 404")
void getProduct_notFound_returns404() {
given()
.when().get("/api/v1/products/999")
.then()
.statusCode(404);
}
}@TestHTTPEndpoint binds the test to a resource class instead of hardcoding paths:
@QuarkusTest
@TestHTTPEndpoint(ProductResource.class)
class ProductResourceTest {
@Test
void getProduct_notFound_returns404() {
given()
.when().get("/999") // resolved relative to ProductResource's @Path
.then()
.statusCode(404);
}
}Full CRUD Flow
@QuarkusTest
class ProductIntegrationTest {
@Test
@DisplayName("Full CRUD flow works end-to-end")
void crudFlow() {
// Create
Long id = given()
.contentType(ContentType.JSON)
.body("""
{"name": "Widget", "price": 10.00}
""")
.when().post("/api/v1/products")
.then()
.statusCode(201)
.extract().jsonPath().getLong("id");
// Read
given()
.when().get("/api/v1/products/{id}", id)
.then()
.statusCode(200)
.body("name", is("Widget"));
// Delete
given()
.when().delete("/api/v1/products/{id}", id)
.then()
.statusCode(204);
given()
.when().get("/api/v1/products/{id}", id)
.then()
.statusCode(404);
}
}Mocking CDI Beans
@InjectMock (requires quarkus-junit5-mockito)
@QuarkusTest
class ProductResourceTest {
@InjectMock
ProductService productService;
@Test
void getProduct_notFound_returns404() {
when(productService.findById(999L))
.thenThrow(new EntityNotFoundException("Product not found"));
given()
.when().get("/api/v1/products/999")
.then()
.statusCode(404);
}
}Mocking a REST Client
@QuarkusTest
class ReportResourceTest {
@InjectMock
@RestClient
CustomerApiClient customerApi;
@Test
void generate_returnsReportWithCustomerData() {
when(customerApi.getCustomer(1L)).thenReturn(new CustomerData(1L, "Acme Corp"));
given()
.when().get("/api/v1/reports/1")
.then()
.statusCode(200)
.body("customerName", is("Acme Corp"));
}
}@InjectSpy for Partial Mocks
@QuarkusTest
class GreetingResourceTest {
@InjectSpy
GreetingService greetingService;
@Test
void overridesOnlyOneMethod() {
doReturn("hi").when(greetingService).greet();
given()
.when().get("/greeting")
.then()
.statusCode(200)
.body(is("hi"));
}
}@InjectMock/@InjectSpy only work with @QuarkusTest (same JVM). They do not work with @QuarkusIntegrationTest, because the application under test runs as a separate process with its own, unmodified CDI container.
Dev Services — Built-In Testcontainers
Quarkus starts and wires backing services for you, automatically, with zero test code.
Add the extension for the service you need — no quarkus.datasource.jdbc.url, no container declaration, nothing else:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency>// ✅ No @Testcontainers, no @Container, no manual config - Dev Services does it all
@QuarkusTest
class ProductRepositoryTest {
@Inject
ProductRepository productRepository;
@Test
@DisplayName("Should find products by name containing")
@Transactional
void shouldFindByNameContaining() {
var product = new Product();
product.setName("Quarkus Widget");
product.setPrice(new BigDecimal("10.00"));
productRepository.persist(product);
List<Product> results = productRepository.find("lower(name) like ?1", "%widget%").list();
assertThat(results).hasSize(1);
assertThat(results.getFirst().getName()).isEqualTo("Quarkus Widget");
}
}When you run mvn test (or start quarkus:dev), Quarkus detects that a datasource is configured but no connection URL was given, pulls up a PostgreSQL container via Testcontainers under the hood, points the datasource at it, and tears it down afterwards. The same zero-config mechanism exists for Kafka (quarkus-kafka-client, backed by Redpanda by default), RabbitMQ, Redis, MongoDB, Keycloak, and more.
Useful knobs:
# Disable Dev Services globally
quarkus.devservices.enabled=false
# Disable Dev Services for one datasource only
quarkus.datasource.devservices.enabled=false
# Pin the container image Dev Services should use
quarkus.datasource.devservices.image-name=postgres:18-alpineDev Services requires a running Docker (or Podman) daemon and only activates in dev/test mode — it never runs in production.
When Dev Services Isn't Enough: QuarkusTestResource
Dev Services covers extensions it knows about. For anything else — WireMock to stub a third-party HTTP API, a hand-rolled container, or a resource that needs custom setup — implement QuarkusTestResourceLifecycleManager yourself:
public class WireMockResource implements QuarkusTestResourceLifecycleManager {
private WireMockServer wireMockServer;
@Override
public Map<String, String> start() {
wireMockServer = new WireMockServer(0);
wireMockServer.start();
return Map.of("quarkus.rest-client.customer-api.url",
"http://localhost:" + wireMockServer.port());
}
@Override
public void stop() {
if (wireMockServer != null) {
wireMockServer.stop();
}
}
}@QuarkusTest
@QuarkusTestResource(WireMockResource.class)
class ReportResourceWireMockTest {
// the REST client now points at the WireMock server
}@WithTestResource is the newer, more ergonomic variant of @QuarkusTestResource (repeatable, with a restrictToAnnotatedClass flag) — prefer it in new code; both exist side by side.
@QuarkusIntegrationTest
Runs the artifact your build actually produces — the runnable jar, the native image, or a container image — as a separate OS process, not inside the test JVM.
@QuarkusIntegrationTest
class ProductResourceIT extends ProductResourceTest {
// Reuses every @Test from ProductResourceTest, now run against the packaged artifact
}Key differences from @QuarkusTest:
@QuarkusTest | @QuarkusIntegrationTest | |
| Runs | In the test JVM | As a separate process (jar / native / container) |
| CDI access from test | Yes (@Inject, @InjectMock, @InjectSpy) | No — it's a different process |
| Catches | Logic bugs | Packaging bugs, native-image-only bugs, missing reflection config |
| Speed | Fast | Slower (full startup, no mocking) |
| Maven plugin | Surefire | Failsafe (integration-test + verify goals) |
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>Run native-image verification in CI with:
./mvnw verify -PnativeBecause mocking isn't possible here, keep @QuarkusIntegrationTest classes focused on "does the packaged app come up and serve traffic correctly" rather than business-logic edge cases — those belong in @QuarkusTest.
Test Profiles
Use a QuarkusTestProfile to run the same test class with different config, enabled alternatives, or test resources.
public class MockGreetingProfile implements QuarkusTestProfile {
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("app.notification.enabled", "false");
}
@Override
public String getConfigProfile() {
return "test-mocked";
}
}@QuarkusTest
@TestProfile(MockGreetingProfile.class)
class GreetingServiceTest {
// Runs with app.notification.enabled=false and profile "test-mocked"
}Parameterized Tests
@ParameterizedTest
@ValueSource(strings = {"", " ", "ab"})
@DisplayName("Should reject invalid usernames")
void shouldRejectInvalidUsername(String username) {
var request = new UserRequest(username, "valid@email.com");
assertThatThrownBy(() -> userService.create(request))
.isInstanceOf(ConstraintViolationException.class);
}
@ParameterizedTest
@CsvSource({
"admin@test.com, ADMIN, true",
"user@test.com, USER, true",
"guest@test.com, GUEST, false"
})
@DisplayName("Should check access by role")
void shouldCheckAccessByRole(String email, String role, boolean expected) {
assertThat(securityService.hasAccess(email, role)).isEqualTo(expected);
}Quick Reference
| Pattern | Use For |
@ExtendWith(MockitoExtension.class) | Pure unit tests, no CDI, no Quarkus boot |
@QuarkusTest | In-process tests with real CDI beans and REST endpoints |
@QuarkusIntegrationTest | Testing the built jar/native image/container as a black box |
@InjectMock / @InjectSpy | Mock/spy a CDI bean inside @QuarkusTest (not available in @QuarkusIntegrationTest) |
@TestHTTPEndpoint(Resource.class) | Resolve RestAssured paths relative to a resource class |
| Dev Services (just add the extension) | Zero-config Testcontainers for DB/Kafka/Redis/etc. in dev & test mode |
QuarkusTestResource / @WithTestResource | Custom test infrastructure Dev Services doesn't cover (e.g. WireMock) |
@TestProfile | Run a test class with different config/alternatives |
assertThatThrownBy() | Negative test - expect exception |
verify(mock, never()) | Verify method was NOT called |
Naming Convention
methodUnderTest_condition_expectedResultExamples: createUser_validRequest_returns201, createUser_duplicateEmail_throws409
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

