Book Image

Mockito for Spring

By : Sujoy Acharya
Book Image

Mockito for Spring

By: Sujoy Acharya

Overview of this book

Table of Contents (12 chapters)
Mockito for Spring
About the Author
About the Reviewers

Testing Spring MVC

This section will mock the request and session scope beans with MockHttpServletRequest and MockHttpSession:

  1. Create a dynamic web project, SpringWebTest, add the Spring-mvc jars to the classpath, and modify the web.xml file (stored under <project>/WebContent/WEB-INF/) to enable Spring DispatcherServlet as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="" xmlns="" xmlns:web="" xsi:schemaLocation="" id="WebApp_ID" version="3.0">