Code Trace Based Technique to improve Automated Test Code Coverage

1.  ABSTRACT

Code Coverage by Automated Tests is an important measure of testing. It tells you how much of the code base has been covered during various tests. Eventually better Code Coverage assures the accuracy and completeness of testing.

In this white paper, I am explaining a technique leveraging SCOV Code Trace to improve Code Coverage.

This technique will leverage a. SCOV Code Trace information and b. Functional knowledge of Tester to provide significant improvement in the Code Coverage.

This technique can be useful for improving Code Coverage of backend as well as UI packages.

2.  INTRODUCTION

There are many ways in SAP to improve code coverage. Few are listed below.

1.  BAPI automation

2.  Transaction Code automation

This code-based technique can be easily used when you have functional knowledge of the application and you are able to map the technical parameters mentioned in the code based to the application fields.

Through this Code Based Technique, we will get more insight of the packages and eventually our knowledge base will be enhanced.

3.  PROBLEM DEFINITION

To improve code coverage, we were automating (HTML?) UI & R3 transactions of application without knowing how many lines of code, Test automates will be covering. Because we were not looking to the code base behind the application before automating it. This way we were not able to optimize the process of automation for maximum code coverage.

4.  CASE STUDY

To check and track the code coverage in SAP systems, SAP has its own tool known as ‘SCOV’. SCOV is a very powerful system-wide runtime analysis tool provided by SAP for collecting, monitoring and analysing the code coverage of test suits such as self-tests, unit tests, integration test & quality tests.

We were always using SCOV to see the reading of code coverage for packages. We never tried to deep dive inside SCOV and find out information about processing code blocks of package. SCOV can also give us information whether all blocks of the code have been tested or not. We can see this in the detailed view of SCOV.

Enter relevant packages into SCOV.

SCOV will display code coverage results for every package like shown below.

Further SCOV can display the detailed view of processing blocks within the packages which we need to analyze and utilize for optimizing code coverage.

1.  SOLUTION DETAILS

In Code-Based Technique I deep dived into the detailed view of SCOV to know the processing blocks inside the package.

On double click of package, you will get the object list of the package.

Upon double click of any object, SCOV will navigate to processing blocks of the concerned object.

Upon double click on any processing block you will be navigated to code base of the processing block.

Code base is highlighted with ‘RED’ background indicates that this processing block has not been covered during testing.

Now comes the functional knowledge in play. By looking at the code base of processing block which is in this case method ‘VALIDATE_STREET_TYPE’ of class ‘CL_HRPA_INFOTYPE_0006_BR’, I got to know that this processing block will be executed when I will enter street name in the address infotype 0006.

I also got the technical field name from the code base which is ‘STRAS’. I validated this field name with R3 application.

The same application exists on UI also and the same code based is used for both the R3 as well as web-dynpro UI.

We can automate this UI either with UFT tool or START tool.

I automated this UI using UFT tool and observed that code base for both the UI package and R3 package improved. Also, I checked the processing block’s code in SCOV which was completely covered.


Now the code base is highlighted with ‘GREEN’ hence it means that this processing block is completely covered in testing.

Similar approach I followed for all other processing block of this package ‘PAOC_PAD_INFTY_0006_BR’ and I got the below SCOV reading for the package.

5.  SUCCESS STORY

I have applied this Code-Based code coverage technique on two modules and although some more automation can still be done the results as of now are very encouraging and significant.

For first module (PA- Infotype Packages):

Total No. of Statement / Statement covered Before Code-Based automation / Statement covered after Code-Based automation / % Improvement
17484 / 2368.45 / 7388.05 / 28.71

For second module (MSS):

Total No. of Statement / Statement covered Before code based automation / Statement covered after code based automation / % Improvement
16643 / 1909.293 / 2832.517 / 5.55

6.  SUMMARY

Ø  We can use Code-Based technique to improve the Code Coverage of Automated/ Manual Tests significantly.

Ø  This technique will leverage the functional knowledge of tester.

Ø  This technique will use the detailed display functionality of SCOV.

Ø  By using this technique, we can be assured that which code is getting covered during testing.

Ø  Code Coverage for Packages of backend as well as UI can be improved.

Author Biography

Rashmi Singh

Quality Associate at SAP Labs India

Experience: 5+ Years of IT experience in testing

THANK YOU!