2

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?

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I know this. But there is nothing about how to create fixtures, how to check that test database has the same structure as dev. Should I use in-memory database or no.
You can use liquibase or flyway to manage deltas in your scripts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.