How to test a controller in Spring Boot - a practical guide

There are different ways to test your Controller (Web or API Layer) classes in Spring Boot, some provide support to write pure Unit Tests and some others are more useful for Integration Tests. Within this post, I���ll cover the main three test approaches available for Spring: using MockMVC in standalone mode, MockMVC together with SpringRunner, and using SpringBootTest.







Updated: Code examples use Java 14 and Spring Boot 2.3 with JUnit 5.


Table of Contents


Introduction
The sa...
 •  0 comments  •  flag
Share on Twitter
Published on June 03, 2020 22:10
No comments have been added yet.