spring-boot-testing-strategylisted
Install: claude install-skill lgzarturo/codeconductor
# Testing Strategy
## Testing Pyramid
```text
/\
/ \
/ E2E\ 10% — full API, happy path + main error cases
/------\
/ Integ \ 20% — components with real dependencies (DB, HTTP)
/----------\
/ Unit \ 70% — isolated, mocked dependencies, fast
/______________\
```
Unit tests are the foundation. They are fast, deterministic, and cheap to run.
Integration tests validate that components work together. E2E tests validate
that the system works end to end — keep them minimal.
If you find yourself writing more integration tests than unit tests, the code
under test has too many responsibilities bundled together.
## Test Naming Convention
Format: `should [expected behavior] when [condition]`
```kotlin
@Test
fun `should return user when found by id`() { ... }
@Test
fun `should return 404 when user does not exist`() { ... }
@Test
fun `should throw ConflictException when email already exists`() { ... }
@Test
fun `should not return deleted users in list`() { ... }
```
Group related tests with `@Nested`:
```kotlin
@ExtendWith(MockKExtension::class)
class UserServiceTest {
@Nested
inner class GetById {
@Test
fun `should return user when found`() { ... }
@Test
fun `should return NotFound when user does not exist`() { ... }
}
@Nested
inner class Create {
@Test
fun `should create and return user when email is unique`() { ... }
@Test
fun `should throw C