简体   繁体   中英

Spring boot configure test database

I need to add tests to my Spring Boot project. With rails framework there is dev and test databases which are created when new project is started. Migrations are applied to both databases to keep the database schemas equal. Unfortunately I didn't find the documentation on how to configure test environment database in Spring boot and how to get the database structure equal to dev.

What is the best practice for testing in Spring Boot? How to setup and add test-data for the test environment? Is there any examples?

You can use profiles in spring which allow to use different configuration. So in DEV Profile you tell spring you want to point to dev database but in TEST Profile run in another database.

Check this link: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html

If you want to manage delta scripts you can use flyway or liquibase. Both are supported by spring-boot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM