02-20-2018 8:29 AM
Hello,
i want to test a Methode that calls a provate Methode of the same class. This provate Methode i want to double, using the double Framework.
The Problem i face is, how to tell SAP to use the doubled Methode?
Can anybod help me?
What i got so far is:
DATA: lo_double TYPE REF TO z_cl_double.
lo_double ?= cl_abap_testdouble=>create( 'Z_IF_ADAPTER' ).
cl_abap_testdouble=>configure_call( lo_double )->returning( '10' )->ignore_all_parameters( ).
lo_double->b( ).
But how to tell my class to use the doubled Methode?
Thanks a lot,
Markus
03-29-2018 7:51 PM
Here is a little example. Does this help?
CLASS tcl_testdouble DEFINITION FOR TESTING
RISK LEVEL HARMLESS
DURATION SHORT.
PRIVATE SECTION.
METHODS test_data_call FOR TESTING.
ENDCLASS.
CLASS tcl_testdouble IMPLEMENTATION.
METHOD test_data_call.
DATA lt_t000_act TYPE STANDARD TABLE OF t000.
DATA lt_t000_exp TYPE STANDARD TABLE OF t000.
lt_t000_act = VALUE #( ( mandt = '000' )
( mandt = '001' ) ).
DATA lo_testdouble_data TYPE REF TO zjkif_testdouble_data.
lo_testdouble_data = CAST #( cl_abap_testdouble=>create(
object_name = 'zjkif_testdouble_data'
* double_name =
) ).
cl_abap_testdouble=>configure_call( double = lo_testdouble_data )->returning( value = lt_t000_act ).
lo_testdouble_data->get_t000_data( ).
DATA(lo_cut) = NEW zjkcl_testdouble( lo_testdouble_data ).
DATA(lt_t000) = lo_cut->get_t000_data( ).
lt_t000_exp = VALUE #( ( mandt = '000' )
( mandt = '001' ) ).
cl_abap_unit_assert=>assert_equals(
EXPORTING
act = lt_t000 " Data object with current value
exp = lt_t000_exp " Data object with expected type
).
ENDMETHOD.
ENDCLASS.
02-11-2021 11:09 PM
Did you find the answer markus.lauxen ?
I am searching for the same on how to mock another method B of the same CUT class which is called by A