mcpField
J
java-testing-advanced

java-testing-advanced

github.com/pluginagentmarketplaceTesting & quality41329 installsUpdated 42w ago
Repository

About java-testing-advanced

java-testing-advanced is a skill for Java developers seeking broader test coverage. It outlines integration, contract, mutation, and property-based testing techniques.

Key features

  1. 01Testcontainers integration testing
  2. 02Pact contract testing
  3. 03PIT mutation testing
  4. 04Property-based test generation

Use cases

  1. 01Test against real databases
  2. 02Verify API contracts
  3. 03Find gaps in test suites
  4. 04Generate test cases automatically

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pluginagentmarketplace/custom-plugin-java --skill java-testing-advanced

After installing, type/java-testing-advancedin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

assets/
config.yaml
schema.json
testing-patterns.yaml
references/
GUIDE.md
PATTERNS.md
scripts/
validate.py

Details

From the project README

Java Testing Advanced Skill

Advanced testing techniques for comprehensive test coverage.

Overview

This skill covers advanced testing patterns including Testcontainers for integration testing, contract testing with Pact, mutation testing with PIT, and property-based testing.

When to Use This Skill

Use when you need to:

  • Test with real databases (Testcontainers)
  • Verify API contracts
  • Find gaps with mutation testing
  • Generate test cases automatically

Quick Reference

Testcontainers
@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();
    }
}
Contract Testing (Pact)
@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");
    }
}
Mutation Testing (PIT)
<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-Based Testing
@Property
void shouldReverseListTwiceReturnsOriginal(@ForAll List<Integer> list) {
    Collections.reverse(list);
    Collections.reverse(list);
    // Original order restored
}

Testing Pyramid

     /\        E2E Tests (few)
    /  \       Contract Tests
   /----\      Integration Tests
  /------\     Unit Tests (many)

Troubleshooting

ProblemSolution
Container slowReuse containers
Port conflictsRandom ports
Flaky testsWait strategies

Usage

Skill("java-testing-advanced")

Comments

Markdown supported