What has been missing so far
In one of my last blog posts, I showed you how mock objects can be easily created. I also showed you how mock object's method calls can be counted and how verifications can be implemented, to ensure that a mocked object's method has been called.
Up to now, it was not possible to check, which parameters have been passed.
Ensure, that a mocked object has been called with certain parameters
In the current build, I also included the possibility to verify the parameters that have been passed to a mock object's method.
This is how it works:
First of all, you need to keep track of the mocker object of type ZIF_MOCKA_MOCKER (which means, please do not throw it away ;-) )
By utilizing this mocker object, you can get data about your mocked methods, such as if it has been called with certain parameters or not:
DATA lv_has_been_called TYPE abap_bool. lv_has_been_called = lo_mocker->method( 'get_delay' )->has_been_called_with( i_p1 = 'LH' i_p2 = '300' i_p3 = sy-datlo ).
For further details, please see report ZMOCKA_DEMO that is shipped with the current release.
Only IMPORTING parameters are supported so far, this means no CHANGING parameters can be verified yet.