vendredi 22 mai 2015

Can you get the number of times a method has been called in EasyMock or PowerMock?

Or more specifically, can one count the number of calls that a method has been called, and then use that number to set the number of expected times another method will be called?

For example, if I have:

expect(userManager.enterSuperUserMode()).andReturn(token).anyTimes();
// count the number of calls...

and then

expect(userManager.leaveSuperUserMode(token))   // void method
expectLastCall.times(<number of times su mode was entered>);

is that possible?

As I'm writing this question out, it actually seems very unlikely since this is all pretty static when the test is replay()ed... maybe a different approach would be sufficient? or is this information that has to be known ahead of time?

Aucun commentaire:

Enregistrer un commentaire