“If you want something new, you have to stop doing something old” – Peter F Drucker
There are many like me who must have been curious to know more about Code coverage and BAPI automation.
That’s when an idea struck me to write a blog on BAPI Automation. I would like to share some best practices during BAPI automation as a set of guidelines. But before that we must know the answers to some questions.
What is Code coverage?
Code coverage is a measure of the percentage of your code base covered via tests conducted (manual/automation).
A higher degree of code coverage implies optimized testing leading to robust products.
Why Measure Code Coverage?
we measure code coverage for the following reasons:
- To know how well our tests actually test our code
- To ensure that most of the highly important scenarios which are part of our code base are covered via testing
- To maintain the test quality over the lifecycle of a project
Keeping track of code coverage can help you to get an answer about whether you test enough. It does this by showing the ratio between tested and untested code. In order to improve the code coverage, we need to target different technical aspects of a product.
It has been discovered via various POCs done by our teams that BAPI Automation is one of the easiest and effective methods to boost code coverage.
What is BAPI and What are its uses?
BAPI (Business Application Programming Interface) is a set of interfaces to object-oriented programming methods that enable a programmer to integrate third-party software into the proprietary R/3 product from SAP. For specific business tasks such as uploading transactional data, BAPIs are implemented and stored in the R/3 system as remote function call (RFC) modules.
Technically, BAPIs are defined as API methods of SAP business object types. These business object types and their BAPIs are described and stored in the Business Object Repository (BOR). A BAPI is implemented as a function module, that is stored and described in the Function Builder.
How to find BAPIs for automation?
To find BAPIs in a given system, you need to start with packages relevant to your area. While we have transactions like SE37 & SE80 as options to find BAPIs existing within any package, the easiest and accurate way to find your list of BAPIs is Using the Report developed by my colleagues Sagar & Nisha.
This new report has been co-developed by Sagar Mopagar & Nisha Agrawal.
Report(Z_VIEW_BAPIS) accepts a list of packages (considered for code coverage) as input (stored in local text file), searches within the Repository Information System to fetch the list of packages with BAPIs and subsequently downloads all relevant BAPIs to local folder.
This significantly reduces the time taken to check for BAPIs in a long array of packages, considering that SE37 is unable to handle it.
Soon this will be available as an eCATT script ready to hunt BAPIs in any system
Refer following video to understand steps 1 through 3 explained above— How to Use Z_VIEW_BAPIS
A BAPI needs to be tested with proper understanding of its functionality. So, a Test Template has to be created before automation which contains BAPI’s technical information along with test conditions to describe functionality of BAPI. The idea behind creating Template is to capture the required information needed for BAPI automation which can easily be referred by people in future.
But to simplify this template creation part and to save time, now Report(Z_GENERATE_TEMPLATE) is also created by Sagar which accepts a BAPI Name as input and automatically generates Test Case based on template attached above.
You can add the Test Conditions and Expected Output in the respective sections of the TC generated.
You may further apply a Macro (Refer text file attached) to give finishing format.
Refer below video to understand how to use the report Z_GENERATE_TEMPLATE and also how to apply the above provided macro to your generated template – How to Use Z_GENERATE_TEMPLATE
To make the process of ‘BAPI automation for improving code coverage’ more convenient and systematic, efforts have been made to provide above mentioned two tools. I hope this blog will be helpful for everyone who would like to contribute towards improving code coverage through BAPI automation.