From the course: Advanced Spring: Effective Integration Testing with Spring Boot
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Which type of web controller responsibilities to test?
From the course: Advanced Spring: Effective Integration Testing with Spring Boot
Which type of web controller responsibilities to test?
- Testing Web Controllers is easy. We can just call business logic and we're done, or maybe not, How do you ensure that endpoint is really exposed on a certain URL? How can you ensure that proper validation has been performed? And how can you prove that exceptions in your applications are translated into right messages and status code for the user? As you can see, there are plenty of other responsibilities that are happening around the controller. Let's review them and see how we can run our integration tests against them so we are more confident that our application is properly covered with testing. Here's an example of a simple RestController. For each request, the controller does the following. First, listen to HTTP request, response to certain URLs, HTTP methods, and content types. Two, deserialized input, pass the incoming HTTP requests and then create Java objects from variables in the URL, HTTP requests parameters and request body. Three, validate input. Controller checks if…
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.