Hello All,
I have been using test_double framework to test & analyze the methods in our classes. Normally, since most of our methods only include select and loop statements, I was doubling the method and inserting the mock data to the environment. But one of our method is calling some functions such as "EQUIPMENT_READ" and some other functions to fill some structures. For that reason, only mocking and filling the tables in the method is not enough to pass these functions, these functions expect real deep tables to be filled in order to give some result. My question is how to bypass these functions without filling the tables with mock data or if mock data filling is required, how to handle that in the most possible way? The original method calls the below function:
call function 'EQUIPMENT_READ' exporting equi_no = ls_result-eq_number importing equi = ls_equi eqkt = ls_eqkt exceptions auth_no_begrp = 1 auth_no_iwerk = 2 auth_no_swerk = 3 eqkt_not_found = 4 equi_not_found = 5 equz_not_found = 6 iloa_not_found = 7 auth_no_ingrp = 8 auth_no_kostl = 9 err_handle = 10 lock_failure = 11 ##NUMBER_OK auth_no_badi = 12 others = 13.
In the test method although I fill the below methods, it doesnt help to fill the ls_equi & ls_eqkt since in a deep layer it still searches for some buffered tables. Test Method:
Test Method:
class-data: environment type ref to if_osql_test_environment. rt_equi = value #( ( equnr = 'TU_NUM_1' eqart = 'IDMRDTL' ) ( equnr = 'TU_NUM_2' eqart = 'IDMRDSU' ) ). environment->insert_test_data( i_data = rt_equi ). rt_eqkt = value #( ( equnr = 'TU_NUM_1' spras = 'E' eqktu = 'EQUIPMENT_TXT_1') ( equnr = 'TU_NUM_2' spras = 'E' eqktu = 'EQUIPMENT_TXT_2') ). environment->insert_test_data( i_data = rt_eqkt ). rt_equz = value #( ( equnr = 'TU_NUM_1' datbi = '01012020' eqlfn = '001') ( equnr = 'TU_NUM_2' datbi = '01012020' eqlfn = '001') ). environment->insert_test_data( i_data = rt_equz ).