API Automation using SAP S/4 HANA Test Automation Tool
The SAP S/4HANA Cloud Test Automation Tool is a cloud native application, with a no-code approach towards automation. The tool helps in accelerating business process testing and regression tests. The in-built recording functionality allows the user to create or adapt scripts based on the customer requirements. End users could record new test scripts or edit already delivered Standard Business Process Automates and build up their regression test suite. The tool until recently only supported standard UI Automation as a way of creating automates, but with the 2105 release we have bundled along with the tool the ability to create API automates as well.
Test automation tool supports the automated test processes built on UI steps where each step has multiple actions which are based on UI flow in a particular FIORI application. The automates might be impacted by changes in underlying application as part of the regular software upgrades which we provide. Executing test cases using the API framework will always be faster than the UI approach Considering these facts, API based execution brings out the following advantages:
- Robust – Since API automates are not UI dependent and are completely based on standard APIs delivered, it makes the framework less error prone and provides a robust feature to an end user.
- Performance – It takes minimal amount of time to execute an API as there is single action present for each process step, hence enabling quick execution.
- Extensibility – API automates enable an end user to extend API payloads to innumerable line items. This can simply be achieved using Copy-Paste functionality in the smart payload tree structure.
The newly introduced API automation framework is extremely user friendly and coupled within the test automation tool. We can also add automation scenarios which could contain the chaining of both UI and API process steps. The API Framework is based on whitelisted APIs that are available on API Hub and it supports both ODATA APIs and SOAP APIs (synchronous) and allows an end user to create an automated test case or process using a particular API. Based on the API selected, one can perform different operations (Create/Read/Update/Delete) on multiple entities present for that API.
For creation of an API automate, an end user will be provided with a guided step-by-step wizard wherein one has to select API Type (ODATA/SOAP) and a particular API from the provided value help.
The Test Automation Tool is designed to support both Business users and more experienced technical users as well. The guided wizard simplifies the process of creating an API test process with ease. Once the desired API is selected, one needs to select Entity types, methods, Operation Types, Entity Operations based on the API type selected.
In case where API requires an input payload, a payload structure will be provided to the end user for populating the payload values so that the test case can be generated.
Payload Structure can be viewed in two ways (as shown in below screenshots):
- Smart View: Payload will be visible in tree table format i.e hierarchical structure that would be easy to understand and manipulate for business users.
Here user can perform multiple operations on payload:
- Copy and Paste – Used to extend payload (e.g extending line items of an entity)
- Delete – Used to delete a certain payload property (if applicable)
- Undo and Redo – To undo and redo the changes
- Expand All – To expand the tree structure to the lowest level
- Collapse All – To collapse the tree structure
- Code View: Payload will be visible in technical format (json/xml) that would be useful for technical users.
As a user, you will have the provision to assert and export data from the API response also. Once an API automate is generated, the same can be consumed in Test Your Processes application for execution.
For API execution to take place, a communication role needs to be setup as per communication scenario/arrangement maintained for a particular API.
Once executed, one will be able to view API logs having below information:
- Request Information – API URL and Used Variables
- Input Payload – Payload structure with values
- API Execution Response – Actual API response
- Assertions (Check Conditions) – Status (Success/Failed)
- Export Response – Exported data
For populating the values in an API automate payload, user will have the provision to select any value from the provided value help for each input field in payload.
Using value help, one can select any of the following options (as shown in below screenshot):
- System Variables – Predefined variables
- Step Variables – Previous Step variables
- Bind with TDC – TDC parameters
For TDC binding in payload, user needs to make sure that TDCs are added for a particular test process or test plan. Then using the value help, any TDC and the corresponding parameters can be selected for binding payload property.
In case user wants to bind TDC data with complete payload structure, ‘Bind TDC Field’ feature can be used using which mapping (Auto-bind and Manual) can be done for API payload and TDC data.
An API automate can be used/executed as per below use cases:
An API automate can be used with any UI automate thereby allowing chaining of UI and API automates.
e.g., In a test process, Sales Order can be created using UI automate and Outbound Delivery can be created using API automate and vice versa.
Process steps from an API automate can be imported to any other automate. Please note that it might require necessary changes (e.g., data binding changes) depending on the step position where it is getting imported.
It is also possible for an end user to replace an UI automate with its corresponding API automate. Replacement can be done using provided value help feature for process steps where one can select the new step that will replace the existing step.
e.g., In a test process having UI automate for Sales Order/Credit Memo/Debit Memo etc. , the same can be replaced with API automate created for Sales Order/Credit Memo/Debit Memo.