Unit testing of controllers with a security layer
In this new section, we will deal with testing controller classes. Why do we have a different test approach for controller classes? The request and response can be represented as JSON objects, similar to a real Request and Response, not like the objects in our project. This will help us check that everything is OK to accept requests and also assert the JSON response if they match the requirements. We will discuss some new annotations and next, we will focus on how to implement these new annotations for AuthorControllerTest
step by step.
Key annotations for Spring MVC controller testing
Spring model-view-controller (MVC) testing uncovers a wealth of annotations that are crafted to simplify and improve our testing endeavors. Each annotation has a purpose, allowing us to replicate an environment that closely resembles our application with a focus, on the MVC layers and their interactions with security settings. Let’s delve...