Advanced testing - Testcontainers, contract testing, mutation testing, property-based
Advanced Java testing with Testcontainers, Pact contract testing, mutation testing, and property-based tests. Use when you need real database integration, API contract verification, or automated test case generation.
/plugin marketplace add pluginagentmarketplace/custom-plugin-java/plugin install pluginagentmarketplace-java-development-assistant@pluginagentmarketplace/custom-plugin-javaThis skill is limited to using the following tools:
assets/config.yamlassets/schema.jsonassets/testing-patterns.yamlreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyAdvanced testing techniques for comprehensive test coverage.
This skill covers advanced testing patterns including Testcontainers for integration testing, contract testing with Pact, mutation testing with PIT, and property-based testing.
Use when you need to:
@Testcontainers
@SpringBootTest
class OrderRepositoryIT {
@Container
static PostgreSQLContainer<?> postgres =
new PostgreSQLContainer<>("postgres:15")
.withDatabaseName("test")
.withUsername("test")
.withPassword("test");
@Container
static KafkaContainer kafka =
new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.4.0"));
@DynamicPropertySource
static void configure(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", postgres::getJdbcUrl);
registry.add("spring.kafka.bootstrap-servers", kafka::getBootstrapServers);
}
@Test
void shouldPersistOrder() {
Order saved = repository.save(new Order("item", 100.0));
assertThat(saved.getId()).isNotNull();
}
}
@ExtendWith(PactConsumerTestExt.class)
class UserServiceContractTest {
@Pact(consumer = "order-service", provider = "user-service")
public RequestResponsePact createPact(PactDslWithProvider builder) {
return builder
.given("user exists")
.uponReceiving("get user request")
.path("/users/1")
.method("GET")
.willRespondWith()
.status(200)
.body(new PactDslJsonBody()
.integerType("id", 1)
.stringType("name", "John"))
.toPact();
}
@Test
@PactTestFor(pactMethod = "createPact")
void testGetUser(MockServer mockServer) {
User user = client.getUser(mockServer.getUrl(), 1L);
assertThat(user.getName()).isEqualTo("John");
}
}
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.15.0</version>
<configuration>
<targetClasses>
<param>com.example.service.*</param>
</targetClasses>
<mutationThreshold>80</mutationThreshold>
</configuration>
</plugin>
@Property
void shouldReverseListTwiceReturnsOriginal(@ForAll List<Integer> list) {
Collections.reverse(list);
Collections.reverse(list);
// Original order restored
}
/\ E2E Tests (few)
/ \ Contract Tests
/----\ Integration Tests
/------\ Unit Tests (many)
| Problem | Solution |
|---|---|
| Container slow | Reuse containers |
| Port conflicts | Random ports |
| Flaky tests | Wait strategies |
Skill("java-testing-advanced")
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.