How to test Model class equals() method. Getting following issue.
<<< FAILURE! - in EmployeeTest
testEquals(EmployeeTest) Time elapsed: <<< ERROR!
org.mockito.exceptions.misusing.UnfinishedVerificationException:
Missing method call for verify(mock) here:
-> at EmployeeTest.testEquals(EmployeeTest.java:20)
Example of correct verification:
verify(mock).doSomething()
Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.
Mocking methods declared on non-public parent classes is not supported.
---------------------------------------------------------------------------------------
private static Employee mockedEmployee;
private static Employee employee;
@BeforeClass
public static void setup() {
mockedEmployee = mock(Employee.class);
employee = new Employee("first", "last");
when(mockedEmployee .getFirstName()).thenReturn(Employee.getFirstName());
}
@Test
public void testEquals() {
Mockito.verify(mockedEmployee).equals(employee);
}