Integration Testing with Spring
summary
Shows concrete Spring TestContext usage with JUnit 5, a Spring Data JPA repo and MySQL/H2 demos showing a repeated test leaving the DB dirty. Fixes compared: @DirtiesContext forces context recreation per test (correct but slow), @Transactional rolls back tests and is much faster in benchmarks from 100 to 2000 rows, but fails if inner calls use REQUIRES_NEW which commits. Also covers TestExecutionListeners needing mergeMode to preserve the transactional listener and using active profiles to swap DB configs.
AI-written summary · about
