2

by default spring-boot does a lot of auto-discovery and registration of components based on classpath. same goes for tests. but let's say i want test my DAOs that uses spring-jpa. so there is no point in loading everything except Db layer (flyway, @Repository, datasource) as it takes much more time to run such tests.

how can i run tests that configure only this part of whole spring context?

1 Answer 1

2

The @DataJpaTest annotation was created exactly for this use case: https://spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4#testing-the-jpa-slice

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

Comments

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.