Checking the number of times a method has been called
bowdi opened this issue · comments
bowdi commented
Hi @bobalicious! Love the project!
Is there any way we can tell how many times a method has been called?
Some use cases for this feature:
- we're not worried about what parameters have been passed to a method, just that it has been called x times.
- asserting that some methods are called, and ignoring other calls
- ignoring the order methods are called in, but asserting they have been called
Rob Baillie commented
Sorry - no idea how I missed this, and it's probably way too late for you.
All you can do at the moment is 'Spy' this after the call.
For example:
Integer numberOfCalls = controller.countOf( 'methodToCheck' )
meaning you can:
Assert.areEqual( 4, controller.countOf( 'methodToCheck' ), '"methodToCheck" is called 4 times );