Stage 02 · Tests · 5 min
Generate Tests
Generate a full test suite covering happy paths, edge cases, and failure scenarios
TALKING POINT · #13
- Testing is a core part of any software delivery lifecycle — industry standards like CI/CD, DevSecOps, and agile all mandate that code is validated before it ships. We'll ask Bob to generate a full test suite covering happy paths, edge cases, and failure scenarios — no manual test writing required.
Prompts
2a · Generate Tests
▼
Generate JUnit 5 integration tests for the payment API.
Cover: successful authorization, declined card, capture after auth,
refund after capture, invalid card number, duplicate refund attempt.
Use MockMvc. Assert HTTP status codes and response body fields.
Target 80% code coverage.
Use Java 17. Generate tests for the payment-app-java17 directory.
Generate a report with name PaymentApiIntegrationTestCoverageReport.md.
PRESENTER NOTE · #14
Before writing any code, Bob will first read the existing source files to gather context — it needs to understand the controllers, models, and endpoints before it can write meaningful tests.Once it has enough context, Bob will create a to-do list and work through each item — files are created one by one and checked off as complete.
What to do with the report: walk the audience through the summary — highlight pass/fail counts, coverage percentage, and any flagged edge cases. This is the kind of output a developer would normally spend hours producing manually.
TIP · #41
You should expect all tests to pass ✅ — when this was last run, all 18 tests passed. Cost: ~0.17 bobcoins.
TIP · #42
JaCoCo (Java Code Coverage) — a library that measures how much of your code is exercised by tests. It generates the coverage percentage report. MockMvc — a Spring testing framework that lets you simulate HTTP requests to your REST endpoints without starting a real server, making tests fast and isolated.