Spring Applications
Exercise: Todo REST Testing
-
Add the Spring starter
spring-boot-starter-webmvc-test to the todo REST service.
-
Add the 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.
-
Use the RestTestClient to implement the following tests:
TodoControllerMockTest tests only the REST controller, uses a mock environment and mocks the repository
TodoControllerMockIT tests the whole REST service using a mock environment
TodoControllerIT tests the whole REST service using a running server
Solution