Can someone explain replayAll() and VerifyAll() in details with some example. As replayAll() is still bit clear but not able to understand what verifyAll() exactly does. I have some test cases that runs successfully even i don't use verifyAll(). Can someone provide the sample code snippet which describe importance of verifyAll().
I haven't used PowerMock, but I have used other mock libraries with the same concepts.
A mock starts out in record mode where you say what is going to happen. You then switch to replay mode and run the real code. At the end you call verify to confirm what you actually said was going to happen did in fact happen.
run code under test that calls runDatabaseScript()
yes. the code works as intended
Now consider another scenario:
run code under test that is blank/doesn't do anything
fail - we never called runDatabaseScript()
The problem is when you don't call verify. The second scenario doesn't fail because verify isn't called to know you never called runDatabaseScript()