Introduction to mocking techniques

In this section, you will learn about different mocking techniques which will be used for mocking the dependencies of a class. In the example given here, mocking techniques are described using the UserServiceTests class, which comprises of unit tests for the UserServiceImpl class. This class has a dependency, namely, UserDAO, which is a data access object used to interact with the underlying database, and, whose methods such as findByEmail is invoked to find whether a user exists in the database. The given the principles of unit tests, where we need to create test replacements or test doubles for the dependencies, we will create a test double for the dependency, UserDAO. There are three different techniques, ...

Get Building Web Apps with Spring 5 and Angular now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.