
This section explains how to recover when a running measurement prevents you from starting new measurements.
In practice, this situation can come up only if you are doing in line coverage measurements in a single program context. The sample program for the first tutorial is an example of this type of measurement.
Assume, for example, that you are measuring a program that runs an integration test. The program ends with a short dump. You correct the problem and restart your integration test.
To your surprise, the new test run ends with an exception from the Coverage API. The reason: Another measurement is already running. What has happened? The short dump prevented your old inline test from stopping the measurement. It now remains in status active, and prevents you from starting a new measurement.
As long as a measurement is in status 'started', no other measurement that specifies any of the same users can start. How can you resume your code coverage measurements?
Essentially, you just need to reload and stop the measurement. You do the same if you run the Coverage API over extended periods of time.
To reload and stop a blocking measurement in an inline test environment, you can add the following code to your IF_SCV_MEASUREMENT->START method call.
DATA: measurement TYPE REF TO if_scv_measurement,
execution_error TYPE REF TO cx_scv_execution_error.
* Catch an operation exception when starting a measurement.
TRY.
measurement->start( ).
CATCH cx_scv_execution_error INTO execution_error.
* If the cause is a blocking measurement, then it is
* captured in the exception. You can use it to stop the
* blocking measurement.
IF execution_error->blocking_measurement IS BOUND.
execution_error->blocking_measurement->stop( ).
execution_error->blocking_measurement->finalize( ).
measurement->start( ).
ENDIF.
ENDTRY.
If the exception was raised because of a blocking measurement, then the exception object contains a reference to the blocking measurement in attribute BLOCKING_MEASUREMENT. You can use BLOCKING_MEASUREMENT to stop and finalize the blocking measurement. You can then try to start the new measurement once again.