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 (Feb 14th, 2021): Code examples use Java 15 and Spring Boot 2.4 with JUnit 5. Removed explicit SpringExten...
 •  0 comments  •  flag
Share on Twitter
Published on February 13, 2021 22:00
No comments have been added yet.