Test Environment
Use
You can integrate a simple test environment.
To do so, you need the two OO interfaces IF_TEST_ENVIRONMENT_BRF and IF_TEST_ENVIRONMENT_UI_BRF. SAP provides class CL_TEST_ENVIRONMENT_BASE_BRF that implements the two interfaces.
The context type 0CT001 is linked with test class CL_TEST_ENVIRONMENT_BRF, which itself derives from CL_TEST_ENVIRONMENT_BASE_BRF. You can orient yourself on this class for your own implementation.
Consider the following:
-
The text environment provides only the context with data. If you need other data that is not in the context, the behavior of the system cannot be foreseen.
-
A test will work if each expression of the application that procures data is able to procure this required data itself, even if the application has not been instantiated.
-
If at least one expression calls for an initialized function group, unexpected results can occur. The situation is the same when testing function modules. If the function group has to be initialized first, the result of the test on a single function module is not of any use.
Features
Implementation for BRF Standard Context (0CT001)
In the concrete implementation for context type 0CT001, the following function is available: The context is based on a flat DDIC structure. In accordance with this structure, an SAP List Viewer is set up. For each field of the structure this SAP List Viewer has an input field in which a value can be entered.
When you perform a test, the system fills the structure that has been declared according to the DDIC structure of the context with the values of the fields of the SAP List Viewer.
Function module BRF_RAISE_EVENT_SIMPLE_CONTEXT is then called and thus a BRF event is processed. The result depends on the rules that have been processed. The system returns only the results of the conditions of the rules (for 'real' rules as well as 'mock' rules) to the test environment and displays these results in a second SAP List Viewer.
Adjustment to Other Implementations of a Context:
If you do not want to use the BRF standard context but at least an implementation that is also based on a flat structure, you can adjust the test environment for your context implementation.
Orient yourself on class CL_TEST_ENVIRONMENT_BRF and create a subclass for CL_TEST_ENVIRONMENT_BASE_BRF.
Proceed as follows:
-
Redefine the method GET_FIELDS.
Essentially, you set up the table for the SAP List Viewer in which you can enter the test data.
-
Redefine the method FILL_CONTEXT.
You use this method to fill the context structure with test data.
-
Redefine the method PROCESS_SPECIFIC.
You use this method to call the event with the context data that you created in step 2. It is important that you return the table MT_BRF210 of the event class to the test environment.
-
Create a new context type.
Proceed as follows:
-
Call up transaction BRFIMC01.
-
Enter CL_TCONTEXT_BASE_MNT_BRF as the maintenance class.
-
Enter the test class you created as the test class.
-
-
Create a context in the context type that you have just created.
-
Enter this context in your event (or in all your relevant events).
-
Test your events.