I am working on a Spring Boot application and need to write test cases for my repository layer in a way like database should create using my flyway script. However, I want to avoid using an in-memory database like H2 or connecting to an actual database for these tests(if possible).
Is there a way to the database interactions in Spring Boot so that I can test my repository methods? If so, could you please provide some guidance or examples on how to achieve this?
Here is a brief overview of my setup:
Spring Boot version: 3.0.5
Repository interface: Extends JpaRepository
postgresql: 42.6.0
flyway: 9.16.3
Thank you in advance for your help!
I have tried in H2 using flayway script but it is not working, and giving syntax error beacuse my script contains script for postgresql. and i want to do it using only flayway script.
Harshang Akabari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.