Spring Boot Testing Standards
**Priority: P0 (CRITICAL)**
Universal anti-slop rules (identity fixtures, tautologies, skip/focus, mock echoing, bug-first lock, sleeps, shallow
assertions, coverage): anti-slop-rules.md. Only Spring deltas
follow.
TDD Workflow
- Red: write the failing test (e.g.,
returns 404). - Green: implement minimal code to pass.
- Refactor: clean up while tests stay green.
- Coverage: diagnostic and project-configured; verify risk-weighted critical paths.
Slice And Integration Deltas
- Web slice:
@WebMvcTestloads only the web layer;MockMvcfor HTTP assertions; mock service dependencies with
@MockBean.
- Data slice:
@DataJpaTest; full context:@SpringBootTest. - Real infrastructure (
[BE-TEST-02]):Testcontainersfor DB and queues; avoid H2/embedded databases. - External HTTP:
WireMock; never make real network calls in tests. - Assertions (
[BE-TEST-03]): AssertJassertThatover JUnit assertions; assert domain fields and status codes, not
mere existence.
- Isolation (
[BE-TEST-04]): don't put@MockBeanin base classes; it reloads context per test.