
Wanted but not Invoked Error in mockito and its solution
This happens with mockito when trying to verify the invocation on an object with specific method.
But what happens is you have interacted with other method of that object but not the one mentioned.
If you have an object named CustomerService
and say it has two methods named saveCustomer()
and verifyExistingCustomer()
And mockito looks something like
verify(customerService, atleast(1)).verifyExistingCustomer(customer),
But in your actual service you called the saveCustomer()
at least once.. BINGO you would get that error.
Also Recommended for you
See how you can get started with mockito with simple example
Do you like Algorithms?
Find K complementary numbers from given array
Can you form the longest palindrome from the given random characters?
Jignesh Sheth
did you find any workaround for this problem????
gullele
Hey Jignesh, make sure the one you are calling on mockito and the one on the actual class are the same methods