METHOD cut_method.
...
" Original Call
cl_static_class_name=>method_name
...
ENDMETHOD.
METHOD cut_method.
...
" Replace with
(vairable_name)=>method_name
...
ENDMETHOD.This can be done using one of the two possible approaches.
METHOD constructor.
...
gv_class_attribue = 'CL_STATIC_CLASS_NAME'.
...
ENDMETHOD.METHOD cut_method.
...
lv_class_name_variable = 'CL_STATIC_CLASS_NAME'.
...
ENDMETHOD.CLASS lcl_cut DEFINITION.
PUBLIC SECTION.
...
METHODS : cut_method ...
ENDCLASS.
CLASS lcl_cut IMPLEMENTATION.
METHOD cut_method.
...
ENDMETHOD.
ENDCLASS.Note :
- Method name must be same as in dependency class with all the IMPORT, EXPORT and CHANGING variables.
- In the cut_method of newly created local class; based on some fixed values passed to it, both success and failure scenarios can be simulated.
Based on the approach used to Set Class name, Modify the Class name in Test Environment as shown below.
METHOD utm.
...
mo_cut->gv_static_class = 'lcl_cut'.
...
ENDMETHOD.Note : Either the class attribute should be made public or local class should be made friends with CUT class.
METHOD cut_method.
...
" Add test seam around variable assignment
TEST-SEAM set_static_class_name.
lv_class_name_variable = 'CL_STATIC_CLASS_NAME'.
END-TEST-SEAM.
...
ENDMETHOD.
--------------------------------------------------------------------------
METHOD utm.
...
TEST-INJECTION set_static_class_name.
lv_class_name_variable = 'LCL_CUT'.
END-TEST-INJECTION.
...
ENDMETHOD.METHOD utm.
...
mo->cut_method ...
...
ENDMETHOD.