Short And Concise Test Setup With @DataJpaTest and Testcontainers

Опубликовано: 20 Май 2026
на канале: Philip Riecks
1,703
39

This is the fourth video of the @DataJpaTest mini-series. We'll reduce our test setup and use @Sql to pre-populate data.

More information about the disposable stand-in database of Testcontainers derived from a JDBC URL: https://www.testcontainers.org/module...

Part I:    • Introduction to @DataJpaTest and Pitfalls ...  
Part II:    • Replacing the Default In-Memory Database o...  
Part III:    • Test a Native Query of Your Spring Data JP...  
Part IV:    • Short And Concise Test Setup With @DataJpa...  

Source code: https://github.com/rieckpil/blog-tuto...

Content:

0:00 Inline the configuration with @DataJpaTest
1:18 Using a special JDBC URL to create a stand-in database with Testcontainers
2:36 Use @Sql to pre-populate the database using a custom SQL script

More testing related content is available on my blog: https://rieckpil.de/

» For more deep-dive into testing your Spring Boot persistence layer, consider joining the Testing Spring Boot Applications Masterclass: https://rieckpil.de/testing-spring-bo...

» Revamp your Testing Knowledge with this 14 Days Free Email Course on Testing Java Applications: https://rieckpil.de/getting-started-w...

#DataJpaTest #SpringBoot #Testcontainers