A simple Spring Boot 3 application demonstrating REST endpoints with unit and integration tests, Jacoco coverage, and CLI-based verification.
springboot-demo/
├─ src/main/java/com/example/demo/
│ ├─ DemoApplication.java
│ └─ controller/
│ └─ HelloController.java
├─ src/test/java/com/example/demo/controller/
│ ├─ HelloControllerUnitTest.java # Unit tests
│ └─ HelloControllerIT.java # Integration tests
├─ pom.xml
└─ README.md
| Endpoint | Method | Description | Example |
|---|---|---|---|
/hello |
GET | Returns a greeting | curl "http://<IP>:8080/hello" |
/greet |
GET | Personalized greeting | curl "http://<IP>:8080/greet?name=Prayag" |
/greet |
GET | Default greeting | curl "http://<IP>:8080/greet" |
mvn compilemvn test- Executes unit tests (
HelloControllerUnitTest.java) - Verifies controller methods without starting Spring context.
mvn verify- Runs unit + integration tests (
HelloControllerIT.java) - Uses
MockMvcto test endpoints with full Spring context.
mvn jacoco:report- Open report at:
target/site/jacoco/index.html
mvn spring-boot:run- Runs Spring Boot app on port 8080.
# Hello endpoint
curl "http://<IP>:8080/hello"
# Greet endpoint with name
curl "http://<IP>:8080/greet?name=Prayag"
# Greet endpoint without name
curl "http://<IP>:8080/greet"| Test Type | File | Purpose |
|---|---|---|
| Unit Test | HelloControllerUnitTest.java |
Validates individual controller methods |
| Integration Test | HelloControllerIT.java |
Verifies endpoints in Spring context |
| Coverage | Jacoco | Measures test coverage for all tests |
All tests are passing, and endpoints are verified via curl.
- Java 17
- Spring Boot 3
- Maven
- JUnit 5
- Spring Boot Test
- Jacoco
- CLI (
curl)
Author: Prayag Sangode Date: 16/10/2025