quarkus-tdd
Test-driven development for Quarkus 3.x LTS using JUnit 5, Mockito, REST Assured, Camel testing, and JaCoCo. Use when adding features, fixing bugs, or refactoring event-driven services.
By affaan-m · 2,791 installs
npx skills add affaan-m/ecc --skill quarkus-tdd
Source repository · Upstream listing
Quarkus TDD Workflow
TDD guidance for Quarkus 3.x services with 80%+ coverage (unit + integration). Optimized for event driven architectures with Apache Camel.
When to Use
New features or REST endpoints
Bug fixes or refactors
Adding data access logic, security rules, or reactive streams
Testing Apache Camel routes and event handlers
Testing event driven services with RabbitMQ
Testing conditional flow logic
Validating CompletableFuture async operations
Testing LogContext propagation
Workflow
1. Write tests first (they should fail)
2. Implement minimal code to pass
3. Refactor with tests green
4. Enforce coverage with JaCoCo (80%+ target)
Unit Tests with @Nested Organization
Follow this structured approach for comprehensive, readable tests:
Key Testing Patterns
1. @Nested Classes : Group tests by method being tested
2. @DisplayName : Provide readable test descriptions for test reports
3. Naming Convention : givenX whenY thenZ for clarity
4. AAA Pattern : Explicit // ARRANGE , // ACT , // ASSERT comments
5. @BeforeEach : Setup common test data to reduce duplication
6. assertDoesNotThrow : Test success scenarios without catching exceptions
7. assertThrows : Test exception scenarios with message validation using AssertJ
8. Comprehensive Coverage : Test happy paths, null inputs, edge cases, exceptions
9. Verify Interactions : Use Mockito verify() to ensure methods are called correctly
10. Never Verify : Use never() to ensure methods are NOT called in error scenarios
Testing Camel Routes
Testing Event Services
Testing CompletableFuture
Resource Layer Tests (REST Assured)
Integration Tests with Real Database
Coverage with JaCoCo
Maven Configuration (Complete)
Run tests with coverage:
Test Dependencies
Best Practices
Test Organization
Use @Nested classes to group tests by method being tested
Use @DisplayName for readable test descriptions visible in reports
Follow givenX whenY thenZ naming convention for test methods
Use @BeforeEach for common test data setup to reduce duplication
Test Structure
Follow AAA pattern with explicit comments ( // ARRANGE , // ACT , // ASSERT )
Use assertDoesNotThrow for success scenarios
Use assertThrows for exception scenarios with message validation
Verify exception messages match expected values using AssertJ contains() or isEqualTo()
Test Coverage
Test happy paths for all public methods
Test null input handling
Test edge cases (empty collections, boundary values, negative IDs, blank strings)
Test exception scenarios comprehensively
Mock all external dependencies (repositories, services, Camel endpoints)
Aim for 80%+ line coverage, 70%+ branch coverage
Assertions
Prefer AssertJ ( assertThat ) over JUnit assertions for value checks
Use fluent AssertJ API for readability: assertThat(list).hasSize(3).contains(item)
For exceptions: use JUnit assertThrows to capture, then AssertJ to validate the message
For non throwing success paths: use JUnit assertDoesNotThrow
For collections: extracting() , filteredOn() , containsExactly()
Testing Integration
Use @QuarkusTest for integration tests
Use @InjectMock to mock dependencies in Quarkus tests
Prefer REST Assured for API testing
Use @TestProfile for test specific configuration
Event Driven Testing
Test Camel routes with AdviceWith and MockEndpoint
Use @CamelQuarkusTest annotation (if using standalone Camel tests)
Verify message content, headers, and routing logic
Test error handling routes separately
Mock external systems (RabbitMQ, S3, databases) in unit tests
Camel Route Testing
Use MockEndpoint for asserting message flow
Use AdviceWith to modify routes for testing (replace endpoints with mocks)
Test message transformation and marshalling
Test exception handling and dead letter queues
Testing Async Operations
Test CompletableFuture success and failure scenarios
Use .join() in tests to wait for async completion
Test exception propagation from CompletableFuture
Verify LogContext propagation to async operations
Performance
Keep tests fast and isolated
Run tests in continuous mode: mvn quarkus:test
Use parameterized tests ( @ParameterizedTest ) for input variations
Build reusable test data builders or factory methods
Quarkus Specific
Stay on latest LTS version (Quarkus 3.x)
Test native compilation compatibility periodically
Use Quarkus test profiles for different scenarios
Leverage Quarkus dev services for local testing
Use @InjectMock instead of @MockBean (Quarkus specific)
Verification Best Practices
Always verify interactions on mocked dependencies
Use verify(mock, never()) to ensure methods are NOT called in error scenarios
Use argThat() for complex argument matching
Verify the order of calls when it matters: InOrder from Mockito