Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Various Approaches of Spring Controller Testing

This small repository provides some example Spring Boot Tests verifying the correct implementation of a very simple RestController. (If you are new to this topic, you can start with this "Building a RESTful Web Service" tutorial.)

The tests can be done with a manually wired MockMvc client or with a with a manually wired WebTestClient client.

If the class creation is under the control of Spring, the MockMvc client will by automatically wired and then can be run against a mocked servlet or an embedded server. Similar, WebTestClient client will by automatically wired and then can be run against a mocked servlet or an embedded server. (Both approaches are described here (mock environment) and here (running server).)

However, the straight-forward solution to test by MockMvc is to run a WebMvcTest. Correspondingly, the straight-forward solution to test by WebTestClient is to run a WebFluxTest.

In order to see all the tests succeeding, just check out and run mvn test.

About

Various Approaches of Spring Controller Testing

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages