Randy Randy - 5 months ago 35
Java Question

Mockito java - test method call with different arguments

I'm trying to test this method, to see if searchProfile is called without arguments:

public void searchProfile(Long searchTerm) {
this.searchTerm = searchTerm;

public void searchProfile() {

This is my test case, I call the method with one argument and expect the one without the argument to be called

public void testSearchProfile() throws Exception {
CustomerProfileController sutStub = Mockito.mock(CustomerProfileController.class);



verify(sutStub, times(1)).searchProfile();

How can I make this work? Right now it just gives me an error:

Comparison Failure:

Expected: customerProfileController.searchProfile();

Actual: customerProfileController.searchProfile(0);


You should use


When preparing the mock.