ColdMock Usage Examples

Use facade.methodCallCount('getUserName') to ensure that it has been called 0 times at this point: #facade.methodCallCount('getUserName')#
Calls facade.getUser() and return 'Brian':
Calls facade.getUser() and return 'Yog-Sothoth':
Calls facade.getUserName and returns User object:
Call a method that retuns void:
Call an inherited method:
Call a virtual or dynamically injected method:

Look at the the method call counters, so you can determine if or how many times your method calls ran:

#thisCall#() was called #facade.methodCallCount(thisCall)# time(s)
Use facade.methodCallCount('getUserName') to ensure that it has been called 0 times at this point: #facade.methodCallCount('getUserName')#
Calls facade.getUser() and return 'Brian':
Calls facade.getUser() and return 'Yog-Sothoth':
Calls facade.getUserName and returns User object:
Call a method that retuns void:
Call an inherited method:
Call a virtual or dynamically injected method:

Look at the the method call counters, so you can determine if or how many times your method calls ran:

#thisCall#() was called #facade.methodCallCount(thisCall)# time(s)


You can also look at the TestTrip.cfc to see how mocks can be used within unit tests.