Test Database Access Using @DataJpaTest
Let’s learn to test the database layer by using Spring Framework's @DataJpaTest annotation.
We'll cover the following...
We'll cover the following...
In our todo application, we used Spring Data JPA for database access and implemented JPA repositories such as TodoRepository and TodoTypeRepository to provide CRUD, pagination, and sorting capabilities on the Todo and TodoType entities, respectively.
Let’s look at the integration tests required to test the database access provided by the JPA repositories.
The TodoRepositoryIntegrationTest class
First, let’s create the TodoRepositoryIntegrationTest class in the io.educative.integration package to verify the CRUD methods like ...