Why Code Coverage?
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 tool?
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: http://help.sap.com/saphelp_snc_uiaddon_10/helpdata/en/49/216c634ab514cde10000000a42189b/content.htm?frameset=/en/00/efad813eb24da09f31bda216040995/frameset.htm¤t_toc=/en/64/d255cb986147f3a7bad0a000d88174/plain.htm&node_id=51&show_children=false
- 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 & 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 the 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 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.
- Else if its a dead Code, testers to request the developers to comment or delete the dead code.