Verification is a process where we assert that a certain method was invoked by the code under test. PowerMock provides various ways in which we can perform the verification of a method call. This recipe will cover the steps required to verify a method invocation in various scenarios.
Let's start by verifying an instance method. The
EmployeeService class had a method called
saveEmployee; we are going to implement this method and write tests for it. Fire off your favorite IDE and let's begin.
saveEmployeemethod is to save the employee's information to the database (DB). Here is how the code looks for this method:
/** * The method that will save * the employee ...