I am relatively new to Mockito and Junit in Java. How can I capture or verify the interaction on the argument passed to function that I am testing. Ex-- Main class
public class A{
public void setValues(Person p){
p.setFirstName('Lucky');
p.setLastName('Singh');
// Some more code
}
}
Test class
class Test {
@InjectMocks
A classUnderTest;
@Test
public void tests(){
classUnderTest.setValues(new Person());
// What to do next to verfiy that the setFirstName and setLastName where really called on Person Object as setValues have void return type??
}
}
Now i want to test this setValues method with void return type. I know if return type would have been Person I could have used assert. But I cannot change method defination.
So I want to verify that the call to setFirstName and setlastName is made.
I am using pit-test and the mutation removed call to setFirstName and setlastName is not getting KILLED.
How can I achieve this ??