@ExtendWith(MockitoExtension.class)
class taskTestMain {
@InjectMocks
task task1;
@Mock
private statusRepository statusRepo;
@Mock
status statusRec;
@Test
void test() {
Mockito.when(statusRepo.save(statusRec)).thenReturn(statusRec);
task1.method();
}
}
class task
{
method()
{
statusRec = statusRepo.save(statusRec); //after this step I get Potential stubbing exception
}}
I have tried several ways . I am not able to figure this out. Please suggest how to proceed. Below I have pasted the junit error. task- Strict stubbing argument mismatch. Please check:
- this invocation of 'save' method:statusRepo.save(status@8bffb8b); -> at task.run(task.java:80)
- has following stubbing(s) with different arguments: 1. statusRepo.save(status@26a2f7f9 ); -> at .taskTestMain.test(taskTestMain.java:110) Typically, stubbing argument mismatch indicates user mistake when writing tests. Mockito fails early so that you can debug potential problem easily.
Thanks for your time