There is an interface IF_CRM_PRODUCT_PROXY in CRM which declares almost all function modules from function group COM_PRODUCT_API for product master access.
This interface is implemented by three classes below.
CL_CRM_PRODUCT_PROXY will delegate the call to MOCK_PROXY( for unit test ) or REAL_PROXY( for productive use ) according to different mode in which the code is running. As an application developer, we do not directly call CL_CRM_PRODUCT_PROXY in our application code, but use another wrapper class CL_CRM_PRODUCT_API instead.
For example, I would like to get the product guid for product with id "I042416", I use the following source code:
In productive use scenario, the callstack could be found below:
our test report calls CL_CRM_PRODUCT_API, which calls CL_CRM_PRODUCT_PROXY, which then calls the productive implementation - CL_CRM_PRODUCT_REAL_PROXY. Inside the real proxy, function module COM_PRODUCT_GUID_GET is called.
How to use CRM mock framework to make fake product guid is returned
Suppose in my unit test code, I would like a fake guid "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" is returned by the same source code.
1. Just add the following source code to let CL_CRM_PRODUCT_PROXY know that currently the code is running under mock mode.