Testers from Test teams/organizations test the software application/product using the test cases/test techniques, but it’s very much essential to measure (how much in terms of percentage & What part of) the code that gets tested through the test cases or test techniques to ensure that most significant part of code base developed by the development is executed by tester’s test cases or approaches.
Though the test organizations develop test cases based on the traceability matrix (where requirements are mapped), there could be a chance to miss out the
areas that are not tested by the test cases/test techniques, which leads to the defect leakage to the customer landscape.
In order to prevent defect leakage to the customers & to improve quality of Testing, Code Coverage should be implemented during test execution.
What is Code Coverage?
Code coverage is a measure used in software testing, which would describe the level or degree to which source code of a program has been tested. There are various code coverage tools available in the Industry. SCOV is a transaction or a code coverage tool provided by SAP as part of the ABAP engine.
When to activate Code Coverage?
Code Coverage tool can be activated in test systems during test execution during new development testing or during a New Release & it can also be measured when there are major code changes during a support pack, in order to understand that if the changed areas have good code coverage.
Benefits of Code Coverage
Finds the Cumulative Execution Percentage for the ABAP Packages
By measuring code coverage there is a possibility to identify the presence of dead code or code which is not executed completely.
Helps to increase test coverage.
How to measure Code Coverage in SAP ABAP systems?
Pre-requisite: User through which code coverage measurements would be pulled need to have the role ‘SAP_QAP_COVERAGE_ADMINISTRATOR’ assigned in order to have the administrator rights for using SCOV transaction.
Ensure that Code Coverage analyzer is switched ON in the SAP Test system. If not request system administrator to Switch ON. More details about SCOV:
Carry out the testing activities as usual, Could be manual or automated.
To pull the code coverage details for a ABAP Package, navigate to ‘Details’ under display node, in the tab ‘Main Choice’, enter the ABAP Package/list of packages against which the code needs to be measured and Click on 'Execute'.
System would display the code coverage details for the request ABAP package/s. Please Note: Initially KPIs must be agreed (with stakeholders or Whomsoever as per your organization needs)upon as What %age of Code is Okay to be executed, meaning , if a package has achieved statement coverage of 60% it should be considered as okay and a package which has achieved anything less than 60% should be considered for Improvement.
Code Coverage at the program object level is depicted through color codes as shown below. Green Colored code is executed by testing and Red Colored is not executed during testing.
Next Steps after measuring Code Coverage
Testers to contact the development colleagues to understand that the code which is not executed by testing is a dead code or required code.
If its a dead code, request development team to comment or delete from the Code base.
Else if it’s a required code that should be executed, Create and execute test cases, so that the red colored code is executed by the newly created test case.