Mockito java - 使用不同参数的测试方法调用

Mockito java - test method call with different arguments

我正在尝试测试此方法,以查看是否在不带参数的情况下调用了 searchProfile:

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

public void searchProfile() {
     //...
}

这是我的测试用例,我用一个参数调用方法,并期望调用没有参数的方法

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

    doNothing().when(sutStub).searchProfile();

    sutStub.searchProfile(0L);

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

我怎样才能完成这项工作?现在它只是给我一个错误:

Comparison Failure:

Expected: customerProfileController.searchProfile();

Actual: customerProfileController.searchProfile(0);

你应该使用

Mockito.when(sutStub.searchProfile(Mockito.anyLong())).thenCallRealMethod();

准备模拟时。