From the course: Advanced Spring: Effective Integration Testing with Spring Boot
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Writing integration tests for the service layer
From the course: Advanced Spring: Effective Integration Testing with Spring Boot
Writing integration tests for the service layer
- [Instructor] As we are making our way through the layers, the next one we will tackle is the service layer. Separation of concern, loose coupling, orchestration, caching, are just some of the benefits we will get from the service layer. Now let's write our first integration test that involves interaction between the service and data layers. We want to test that we are able to correctly fetch our student by making a request to the repository and assure the response is as expected. So here we are going to create StudentsServiceTest, as this is an integration test, we'll use SpringBootTest annotation. SpringBootTest works by reading configuration from SpringBootApplication and creates an application context very similar to the one that would be started in a production environment. Because we have a full application context, including web controller services and spring data repositories, SpringBootTest is a very convenient for integration tests that go through all layers of the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.