Developing Java Applications with Spring and Spring Boot
by Claudio Eduardo de Oliveira, Greg L. Turnquist, Alex Antonov
How it works...
The key difference from our previous test is the absence of the @SpringBootTest annotation, which has been replaced with the @DataJpaTest annotation. The apparent simplicity of the test class itself is possible thanks to the @DataJpaTest annotation doing the bulk of the declarations and workload to configure the test environment. If we look inside the annotation definition, we will see a myriad of different internal annotations configuring all the necessary components. The important ones are the @AutoConfigure* annotations, such as @AutoConfigureDataJpa or @AutoConfigureTestDatabase. Those annotations essentially instruct Spring Boot to import the necessary component configurations when bootstrapping the test. For example, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access