amoss icon indicating copy to clipboard operation
amoss copied to clipboard

Checking the number of times a method has been called

Open bowdi opened this issue 3 years ago • 1 comments

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

bowdi avatar Aug 03 '22 15:08 bowdi

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 );

bobalicious avatar Feb 27 '24 12:02 bobalicious