O'Reilly logo

Learning Modular Java Programming by Tejaswini Mandar Jog

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mock testing

The testing which is carried out with the help of mock objects is called mock testing. There are a number of ways which provide the means for mock testing. Let's discover them one by one.

Spring testing framework

Spring provides an API to conduct testing using the mock technique in JUnit. Using this API, we can create mock objects of Request, Response, Filter, and HttpSession, which is otherwise available from the container. All those methods which are dependent on request or user's request and response can now be tested easily without a container. Using this API, tests can be created even before the development of the controller has been completed with mocking or stubbing.

Let's use it in our controller testing which we developed in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required