> For the complete documentation index, see [llms.txt](https://lin-4.gitbook.io/test/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lin-4.gitbook.io/test/unit-test-for-server-side.md).

# unit test for server side

<https://thepracticaldeveloper.com/2017/07/31/guide-spring-boot-controller-tests/>

## Server-Side Tests

There are two main strategies we can identify in Spring: writing Controller tests using the MockMVC approach, or making use of RestTemplate. The first strategy(MockMVC) should be your preferred one if you want to code a *real* Unit Test, while RestTemplate should be used if you intend to write an **Integration** Test. The reason is that with MockMVC we can fine-grain our assertions for the Controller. RestTemplate, on the other hand, will use the Spring’s WebApplicationContext (partly or fully, depends on using the Standalone mode or not). Let’s explain these two strategies in more detail.

<https://spring.io/guides/gs/testing-web/>

<https://springframework.guru/unit-testing-spring-mvc-spring-boot-1-4-part-1/>

<https://howtodoinjava.com/spring/spring-restful/spring-restful-client-resttemplate-example/>

MockMVC:

<https://spring.io/guides/gs/testing-web/>

<https://www.luckyryan.com/2013/08/24/unit-test-controllers-spring-mvc-test/>

<https://thepracticaldeveloper.com/2017/07/31/guide-spring-boot-controller-tests/>

<http://www.baeldung.com/spring-boot-testresttemplate>

<https://www.petrikainulainen.net/programming/spring-framework/unit-testing-of-spring-mvc-controllers-normal-controllers/>
