A collection of small, focused examples for common testing scenarios in Java and Spring Boot.
The goal: show a minimal implementation for each testing approach, including the trade-offs, and provide copy/paste-friendly starting points.
- Java 25 or above
- Maven 4.x
- Modern Docker Installation
Suggestion: Use sdkman to configure java and maven versions.
#!/usr/bin/env bash
./mvnw clean installThis repo is organized as a multi-project Maven project:
modules/auto-configuration— Testing custom auto-configuration classes / custom spring starters using ApplicationContextRunnermodules/bdd— Behavior Driven Development (BDD) tests with Spring, Cucumber, Jupiter, and multiple@CucumberContextConfigurationmodules/containers— Integration tests with real services via Testcontainersmodules/embedded-db— In-memory DB testing patterns (e.g., H2, Derby, HSQLDB)modules/embedded-kafka— Messaging tests with embedded Kafkamodules/localstack— AWS integration-style tests locally with LocalStack and Test Containersmodules/web— HTTP Layer tests via: Mockito, @WebMvcTest, RestTestClient, and TestRestTemplate.