wood burning stoves 2.0*
The moose likes Testing and the fly likes replayAll() & verifyAll() in PowerMock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "replayAll() & verifyAll() in PowerMock" Watch "replayAll() & verifyAll() in PowerMock" New topic
Author

replayAll() & verifyAll() in PowerMock

vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 111

Hi

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().

Thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

Vivek,
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.

Pseudo code:
record:
call runDatabaseScript()
replay:
run code under test that calls runDatabaseScript()
verify:
yes. the code works as intended

Now consider another scenario:
Pseudo code:
record:
call runDatabaseScript()
replay:
run code under test that is blank/doesn't do anything
verify:
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()


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: replayAll() & verifyAll() in PowerMock
 
Similar Threads
Architectural consideration.
software arhitcture books
Developing and Testing Android application
what is the difference paralle GC and CMS?
Extract/Read Data from a file between a particualar time frame