Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

[Bug] in method cl_cds_test_environment=>create_for_multiple_cds

burghard
Discoverer
0 Kudos
637
<a href="/storage/temp/2178746-reproducer.txt" data-attachment="2178746">reproducer.txt</a>

There are two methods in cl_cds_test_environment for creating cds test doubles.

cl_cds_test_environment=>create<br>cl_cds_test_environment=>create_for_multiple_cds 

The second one does not work correctly. The simplest way to see is with this code:

cl_cds_test_environment=>create_for_multiple_cds( i_for_entities = VALUE #( ( i_for_entity = 'I_PRODUCT' ) ) ).<br>cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( 'MARA' ) ) ).

The second call crashes, because the first call executes incorrectly. If we use the create method instead of the create_for_multiple_cds like below, the problem does not occur:

cl_cds_test_environment=>create(  i_for_entity  = 'I_PRODUCT' ).<br>cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( 'MARA' ) ) ).

The difference between the multiple create and the single create method is that the former incorrectly places MARA and MAW1 in this global table:

cl_osql_replace=>replacement_tab

which causes the subsequent attempt to create an osql double for MARA to fail.

By comparing the code of the two methods

cl_cds_test_environment=>create<br>cl_cds_test_environment=>create_for_multiple_cds 

we can see that an if check was forgotten in the second one (see attachment side-by-side.png)

To correct the bug, SAP needs to add the "IF test_associations EQ 'X'." line to method cl_cds_test_environment=>create_mul_cds_test_instance before line 4794.

In the attached reproducer.txt you find a test class that allows you to reproduce the bug and also gives some more insight in the problem (incorrect values in cl_osql_replace=>replacement_tab).

Best regards,

Burghard von Karger

External Consultant at Hugo Boss

1 REPLY 1

moshenaveh
Community Manager
Community Manager
0 Kudos
537

Welcome to the SAP Community! Thank you for visiting us to get answers to your questions.

Since you're asking a question here for the first time, I'd like to offer some friendly advice on how to get the most out of your community membership and experience.

First, please see https://community.sap.com/resources/questions-and-answers, as this resource page provides tips for preparing questions that draw responses from our members. Secondly, feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html as well, as that will help you when submitting questions to the community.

Finally, I recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.

I hope you find this advice useful, and we're happy to have you as part of SAP Community!