Spring Web
Exercise: Todo REST Testing
-
Clone the GitLab repository Todo.
-
Add the Spring Boot starter
spring-boot-starter-webmvc-test to the REST service.
-
Add an SQL file
data.sql that inserts some test data into the H2 database and set the application property spring.jpa.defer-datasource-initialization to true.
-
Implement a unit test
TodoMockMvcTest that only tests the REST controller and mocks the repository using a mock environment and the MockMvc
-
Implement an integration test
TodoMockMvcIT that tests the whole REST service using a mock environment and the MockMvc.
-
Implement an integration test
TodoRestClientIT that tests the whole REST service using a running server and the RestClient.
Solution