Datajpatest Articles
2 articles about Datajpatest. Explore Spring Boot implementation, design, and operations across related topics.
-
How to Load Test Data in Spring Boot Tests Using the @Sql Annotation
Learn how to use the @Sql annotation with @DataJpaTest and @SpringBootTest to declaratively load fixture data for each test. Covers how to use executionPhase and errorMode, the difference from data.sql, and more, with practical examples.
-
How to Write Repository Layer Slice Tests with @DataJpaTest in Spring Boot - Choosing Between H2 and Testcontainers
A guide to writing slice tests focused on the Repository layer using @DataJpaTest in Spring Boot 3.x. Covers automatic rollback, TestEntityManager, switching between H2 and a real database via @AutoConfigureTestDatabase, verifying query methods and @Query, and when to combine Testcontainers — all with practical examples.