Dear community,
I am having an error creating a unit test with RAP. I have the following developments objects:
Now I want to create a simple unit test for an determination of the interface view in which test data for entity A and B is necessary. In my test class I create the test environment like the following:
cds_test_environment = cl_cds_test_environment=> cds_test_environment = cl_cds_test_environment=>create_for_multiple_cds(
VALUE #(
( i_for_entity = 'Z_I_ENTITY_A' )
( i_for_entity = 'Z_I_ENTITY_B')
)
).
DATA my_mock_data TYPE STANDARD TABLE OF Z_A_ENTITY_A.
" Fill my_mock_data with test data values
...
" Insert test data
cds_test_environment->insert_test_data( i_data = my_mock_data ).
The insert_test_data statement fails with the following message “The test double ‘Z_A_ENTITY_A’ not found.
When I change the create_for_multiple_cds statement to use the base views, it works. However, I need to test on interface view level. How is this possible? What can I change in order to enable this?
In the documentation of create_for_multiple_cds it says "This parameter should not be used while writing a unit test. For unit test, the framework will automatically evaluate the first level dependencies in the hierarchy and will create doubles for them". This seems like an explanation why it works when creating the test environment on base view level. However, all attempts from my side to fill the dependecy list manually failed. Also, to me it is not clear whether "hierarchy" here refers to the relationship between Entities (like Entity A and B) or the relationship between base views and consumption views.
Any help is highly appreciated!
Request clarification before answering.
CDS test double mocks data sources that are just one tier below the CDS view under test. In your case, as you want to test the Z_I_ views, change the data type of the mock data from the table type to the base entity type as shown below:
DATA my_mock_data TYPE STANDARD TABLE OF Z_R_ENTITY_A.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.