• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

replayAll() & verifyAll() in PowerMock

 
Ranch Hand
Posts: 157
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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()
 
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic