
A configuration object lets you control how the Coverage API calculates code coverage results. With a configuration object, you can customize the following:
The depth and content of the hierarchy of results that the Coverage API calculates.
Example: By default, the Coverage API calculates results for all of the subpackages and programs in a package that you specify.
With a configuration object, you can ask for only the package aggregate code coverage. Or you can have the result hierarchy stop at a specified level.
The coverage statistics that are included in the results. Example: If you want, you can have only branch coverage statistics returned in a result.
Whether global and local classes in class pools and other types of programs are shown as a separate level in the hierarchy between programs and processing blocks.
You can supply a configuration object to any of the IF_SCV_MEASUREMENT->BUILD...RESULT methods.
You can also save a configuration object as the default configuration of a measurement series. It is then used as the default configuration in all BUILD...RESULT method calls.
If you do not provide a configuration, then the results hierarchy has these default characteristics:
It includes the full hierarchy of subcomponents that are contained in the entities for which you requested results.
All types of code coverage statistics are calculated: branch, statement, and processing block.
Global and local classes in class pools and other programs are shown in their own hierarchy level between programs and processing blocks.
Working with a Configuration Object: Standalone Measurement
Here is sample code for getting a configuration object from a measurement and customizing the way a result is calculated.
DATA: measurement TYPE REF TO if_scv_measurement,
configuration TYPE REF TO if_scv_result_configuration,
result TYPE REF TO if_scv_result,
display TYPE REF TO if_scv_result_display.
* Get the configuration object
configuration = measurement->get_result_configuration( ).
* Truncate the results hierarchy at the program level
configuration->stop_at( ce_scv_node_type=>program ).
* Return only the branch coverage in results
configuration->remove_all_coverage_types( ).
* Constants before SAP NetWeaver 7.0 EHP2 SP5 or 6
configuration->add_coverage_type( IF_SCV_COVERAGE=>CON_BRANCH ).
* Constants after SAP NetWeaver 7.0 EHP2 SP5 or 6
configuration->add_coverage( CE_SCV_COVERAGE_TYPE=>BRANCH ).
* Get the result - the new configuration is used
result = measurement->build_component_result( 'BC-CCM-MON' ).
* Show the configured result
display = cl_scv_coverage_ui=>get_result_display( result ).
display->show_as_fullscreen( ).
Working with a Configuration Object: Measurement Series
In a measurement series, you can save an initial configuration object as the default configuration of the series. The series uses the configuration by default in all results calculations. Here is sample code: Step 2: Setting Defaults for a Measurement Series.
You can override the default by providing an additional configuration object as an argument to a BUILD...RESULT method call.
IF_SCV_RESULT_CONFIGURATION Methods
Here are the configuration methods in overview. The first table shows the methods for tailoring the results hierarchy that is calculated.
|
IF_SCV_RESULT_CONFIGURATION Method |
Use |
|
STOP_AT |
Truncates the results hierarchy after the level that you specify. Level constants are these: CE_SCV_NODE_TYPE=>BLOCK: Processing block CE_SCV_NODE_TYPE=>CLASS: Class (presented as extra level below program) CE_SCV_NODE_TYPE=>PROGRAM: Program CE_SCV_NODE_TYPE=>PACKAGE: Package CE_SCV_NODE_TYPE=>COMPONENT: Application component, as shown in the Package Builder CE_SCV_NODE_TYPE=>SELECTION: The tree is truncated at the respective entities specified with a selection object. |
|
DONT_STOP |
The results hierarchy is calculated to its full depth. |
|
SET_IGNORE_HIERARCHY |
Do not calculate a results hierarchy. Return only an aggregated result for each requested entity. |
|
SET_SKIP_CLASS_LEVEL |
Do not display a separate hierarchy level for global and local classes between the Program and Processing Block levels. For each program, there is only an aggregated result. The next and final hierarchy level is then Processing Blocks. |
Here are the methods for setting the code coverage statistics that are calculated.
|
IF_SCV_RESULT_CONFIGURATION Method |
Use |
|
REMOVE_ALL_COVERAGE_TYPES |
Configures a result to return none of the three types of code coverage statistics. |
|
ADD_ALL_COVERAGE_TYPES |
Configures a result to return all of the three types of code coverage statistics. |
|
ADD_COVERAGE_TYPE |
Configure a result to return one of the three code coverage statistics. In SAP NetWeaver 7.0 EHP2 up to SP5 or 6, the constants are IF_SCV_COVERAGE=>CON_STATEMENT IF_SCV_COVERAGE=>CON_BRANCH I F_SCV_COVERAGE=>CON_PROCEDURE As of SAP NetWeaver 7.0 EHP2 SP5 or 6, the constants are: CE_SCV_COVERAGE_TYPE=>STATEMENT CE_SCV_COVERAGE_TYPE=>BRANCH CE_SCV_COVERAGE_TYPE=>PROCEDURE |
|
REMOVE_COVERAGE_TYPE |
Configure a result not to return a specified type of coverage statistic. The constants are as shown above for method ADD_COVERAGE_TYPE. |
You can restore a configuration to the Coverage API default by calling method RESET_TO_DEFAULT.