I am trying to run integration tests in Java and I have liquibase integrated. Integration tests are running absolutely fine but the tests are referring to MySQL which is running on my localhost instead of H2, because of which my database drops first and then integration tests run. Even if I don't drop the database, it would still do modifications in main db records which is an issue in itself.
This is my application.properties file
spring.datasource.url=jdbc:mysql://localhost:3306/schema
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=none
spring.h2.console.enabled=true
logging.level.liquibase=info
spring.liquibase.contexts=${CONTEXT:some-context}
This is my application-test.properties file
spring.jpa.hibernate.ddl-auto=none
spring.datasource.name=testData
spring.jmx.default-domain=jpa.sample
liquibase.change-log=classpath:/db/changelog/db.changelog-master.xml
liquibase.enabled=true
liquibase.url=jdbc:h2:mem:testData;mode:MySQL
liquibase.user=sa
liquibase.password=
spring.liquibase.drop-first=true
This liquibase.change-log is path to a folder created in my project's resources folder. The only thing that I would like is for my integration tests to create an H2 database and perform all operations instead of referring to the MySQL running on my localhost which my application is using.
I have used this example as a reference: https://github.com/TurgayCan/spring-boot-liquibase-example
Let me know what I can do in this matter. Thank you.
Aucun commentaire:
Enregistrer un commentaire