Testing Java Applications: JUnit 5, Mockito & SpringBootTest
Write professional unit and integration tests using JUnit 5 (`@Test`, `@ParameterizedTest`), Mockito (`@Mock`, `when().thenReturn()`), and `@SpringBootTest` with `@MockBean`.
Testing Pyramid: Unit vs Slice vs Integration
### The Enterprise Testing Pyramid
1. **Unit Tests (JUnit 5 + Mockito)**: Fast, isolated test of single class logic without Spring context (<10ms per test).
2. **Slice Tests (@WebMvcTest, @DataJpaTest)**: Tests specific layer with lightweight Spring context.
3. **Integration Tests (@SpringBootTest + Testcontainers)**: Full end-to-end testing with actual PostgreSQL DB.