This is the third part of my video tutorial which concentrates on unit testing of Spring MVC controllers. To be more specific, this video talks about the unit testing of REST APIs.
The problem is that writing comprehensive and fast unit tests for these APIs has been troublesome. This video demonstrates how we can solve this problem and write readable, comprehensive, and fast unit tests for a REST API by using the Spring MVC Test framework.
This video teaches us four things:
- We learn to write unit tests for controller methods which read information from the database.
- We learn to write unit tests for controller methods which add information to the database.
- We learn how we can transform DTO objects into JSON bytes and send the result of the transformation in the body of the request.
- We learn how we can write assertions for JSON documents by using JsonPath expressions.