Platform agnostic library-less intelligent test automation by reverse engineering product REST API specification
An API reader reads a system application's API specification file and creates a root.yml file containing key:value pairs, in which the keys are objects, and the values are staging_object.yml files. Each staging_object.yml file includes a set of entries, with each entry including a REST operation, a REST endpoint, and a description of the operation to be performed using that entry. An intelligent API converter creates structured object.yml files based on corresponding unstructured staging_object.yml files, and replaces the staging_object.yml files of the root.yml file with the newly created object.yml files. Each object.yml file includes a plurality of entries, corresponding to the entries of the respective staging_object.yml file. Each entry of the object.yml file includes an OPERATION, a JSON payload, and a VALIDATION section. An API builder uses the root.yml file to build a REST API for the system under test which is used to automate testing of the application.
1. A method of automating creation of test scripts to test functionality of a system application comprising:
reading a Representational State Transfer (REST) Application Programming Interface (API) specification file of the system application;
using the REST API specification file to create a root.yml file containing key:value pairs, in which each key is an object from the REST API specification and each value is a staging_object.yml file, each staging_object.yml file having a plurality of staging_object.yml entries, each staging_object.yml entry containing a REST method, a REST end point, and a description of an operation associated with the entry;
converting the staging_object.yml files into object.yml files, each object.yml file having a plurality of object.yml entries corresponding to respective staging_object.yml entries, each object.yml containing an OPERATION parameter containing a REST method and Uniform Resource Identifier (URI), a JavaScript Object Notation (JSON) payload parameter, and a VALIDATION parameter;
using the object.yml files to create a REST API for the system application, the REST API including a plurality of REST endpoints corresponding to the object.yml entries;
executing a series of test operations on the REST API that has been created for the system application, each test operation specifying a respective REST API endpoint and JSON payload, to test functions of the system application;
receiving responses to the series of test operations from the system application;
and validating the responses to determine execution of the system application;
wherein the step of using the object.yml files to create the REST API for the system application comprises, for each object.yml entry:
selecting an object.yml entry, the object.yml entry having the OPERATION parameter containing the REST method and Uniform Resource Identifier (URI), the JSON payload parameter, and the VALIDATION parameter;
using the REST method and URI to build a REST end point corresponding to the selected object.yml entry; and
using a value from the JSON payload parameter to build a payload corresponding to the selected object.yml entry.
2. The method of claim 1 , wherein each staging_object.yml file is an unstructured file corresponding to a respective object of API specification.
3. The method of claim 1 , wherein the description of a given staging_object.yml entry contains parameters describing instances required by the entry.
4. The method of claim 1 , wherein the OPERATION parameter of a given object.yml entry is based on a REST method of a corresponding staging_object.yml entry.
5. The method of claim 1 , wherein the OPERATION parameter of a given object.yml entry includes an operation method and a corresponding Uniform Resource Identifier (URI).
6. The method of claim 1 , wherein the JSON payload parameter of a given object.yml entry is based on a parameter content of a corresponding staging_object.yml entry.
7. The method of claim 6 , wherein when the parameter of the corresponding staging_object.yml entry requires a unique value, a UNIQUE tag is added to the JSON payload based on a datatype of the parameter requiring the unique value.
8. The method of claim 7 , wherein the UNIQUE tag is either a unique string or a unique integer depending on the datatype of the parameter requiring the unique value.
9. The method of claim 6 , wherein when the parameter of the corresponding staging_object.yml entry requires an ID parameter, an AUTOFILL tag is added to the JSON payload.
10. The method of claim 1 , wherein the VALIDATION parameter of a given object.yml entry is based on a description of the corresponding staging_object.yml entry.
11. The method of claim 10 , wherein the VALIDATION parameter is based on a type of action that is supposed to occur when the OPERATION associated with the object.yml entry is implemented on the system application.
12. The method of claim 1 , wherein when the value from the JSON payload parameter is a UNIQUE tag, the method further comprises generating a random number and including the random number in the payload corresponding to the selected object.yml entry.
13. The method of claim 1 , wherein the step of using the REST API as the test environment for the system application comprises:
obtaining a script containing a set of operations describing a test use case scenario to be executed on the system application;
issuing the set of operations on the REST API to the system application; and executing the set of operations by the system application.
14. The method of claim 13 , further comprising using the VALIDATION parameters of the object.yml to validate whether the set of operations of the test use case scenario were properly executed on the system application.