
To make measurement series more convenient, you can store default settings with the series. You can store both the configuration for calculating results and the selection of entities for which coverage results should be calculated. The default settings are automatically used when you calculate results from measurements of the series.
Make default settings before you save a series the first time. You cannot change the default configuration and the default object selection once you have saved a series.
Here is some sample code to show how to make default settings.
DATA: configuration TYPE REF TO if_scv_result_configuration,
series TYPE REF TO if_scv_series,
selection TYPE REF TO if_scv_selection,
repository TYPE REF TO if_scv_repository,
users TYPE if_scv_measurement=>users.
* Set the scope of measurement directly in the series
* Here, activity on all instances of the system will be measured
series->set_local_server_only( abap_false ).
* Also, set the default users directly in the series.
* The user set is saved with the series as the default for
* measurements.
APPEND 'USER01' TO users.
series->set_users( users ).
* Get and set the default object selection
* By default, coverage of MY_PACKAGE will be calculated
selection = series->get_selection( ).
selection->include_package( 'MY_PACKAGE' ).
* Get and set the results configuration.
* Here, only a single aggregated coverage will be
* calculated. For example, Coverage will be
* calculated for MY_PACKAGE, but not for any
* sub-components of MY_PACKAGE. No coverage tree is generated.
configuration = series->get_result_configuration( ).
configuration->set_ignore_hierarchy( abap_true ).
* Save the default configuration and selection
repository->save_series( series ).
As you can see in the sample code, you set the test users and the scope of the measurement (local server or all servers) in the series itself. Both the test users and the scope are saved as part of the default settings of the series. They are used automatically by any measurements that you create in the series.
Note that you can change the default test users and the scope of the measurement on the fly if you need to. Example: You can use IF_SCV_SERIES->SET_USERS to add an additional test user or change the test user before creating a new measurement in a series. The measurement uses the new test-users setting.
Any changes to the test users or scope are saved with the series if you save a measurement of the series. This action performs an implicit save of the series as well as saving the measurement.
The next step is to measure code coverage.
For more information about result configurations and object selections, see Default Settings.
Here is the complete tutorial program.