IP Library › Granted Patent US 11,768,759
Granted Patent B2
US 11,768,759 · App. 17/482,841 · Granted Sep 26, 2023

Method and system for automated testing of web service APIs

Inventors: Ashish Mani Tiwari (Bangalore, IN); Brijendra Sharma (Bangalore, IN)
Assignee: Tata Consultancy Services Limited
G06F11/3684G06F11/3688G06F11/3692H04L67/02
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,768,759
App. No.
17/482,841
Granted
Sep 26, 2023
Kind
B2
Abstract

Existing methods of automated testing of web service APIs require additional tools to extract API related details and configuration files to create test cases. The method and system disclosed herein taps annotations present in code of web service APIs to extract API related details and creates test cases using the extracted data. The method disclosed herein describes an approach to identify resource classes related to a plurality of web service APIs using built-in annotations in code of web application under test. Further, the identified resource classes are scanned to extract API related details (metadata) using built-in annotations and annotations given by a developer. Further, the extracted metadata is forwarded to a test engine server which generates a plurality of test cases using the extracted metadata. Further, the plurality of web service APIs are tested using the generated test cases.

Claims (33)

1. A method for automated generation of test cases for web service Application Programming Interfaces (APIs), the method being implemented by one or more hardware processors and comprising:

receiving, by the one or more hardware processors, a web application comprising a plurality of web service APIs;

identifying, by the one or more hardware processors, a plurality of resource classes corresponding to each of the plurality of web service APIs by an instance of a forwarder using API related annotations present in a code of a package specified in the instance of the forwarder, wherein the forwarder is a library integrated with the web application, and wherein the API related annotations indicate that a class following is an annotation is a resource class;

extracting, by the one or more hardware processors, metadata related to each of the plurality of web service APIs from the plurality of resource classes by the instance of the forwarder using reflection libraries, wherein the extracted metadata for each of the plurality of web service APIs comprises at least one of (i) a Uniform Resource Identifier (URI), (ii) an HTTP Method, (iii) path variables, (iv) headers, (v) request parameters, (vi) a request body structure and (vii) a response body structure identified from built-in annotations in a code of the corresponding resource class, (viii) sequence of call, (ix) method of authentication and (x) special field constraints identified from ApiInfo annotation and AttributeInfo annotation provided by a developer in a code of corresponding resource class, wherein the extracting comprises:

scanning, by the one or more hardware processors, the plurality of identified resource classes observed for a plurality of API related annotations in the code of the identified resource classes, and scanning the plurality of identified resource classes by an object parser utility of the instance of the forwarder;

extracting the metadata from the plurality of API related annotations;

forwarding, by the one or more hardware processors, the extracted metadata to a test engine server to store in a database and

collecting, by the test engine server, the extracted metadata from the database and generate a plurality of test cases as a plurality of web service objects, the plurality of web service objects acting as request payloads to the plurality of web service APIs in the resource classes, wherein each of the plurality of test cases are generated by the test engine server as an HTTP request comprising the path variables, the request parameters, the request body, a Uniform Resource Locator, URL, derived from the URI, the authentication method, the headers and the HTTP method based on the extracted metadata, wherein the test cases are generated for the web service APIs according to the sequence of call, and the request fields are filled based on the special field constraints.

2. The method of claim 1 , wherein the ApiInfo annotation and the AttributeInfo annotation are additional annotations made available for a developer to refine the test cases.

3. The method of claim 2 , wherein the ApiInfo annotation comprises sequence attribute which indicates sequence of call of the web service APIs, a plurality of authentication related attributes and wherein the AttributeInfo annotation comprises a plurality of attributes which facilitate creation of the test cases.

4. A system for automated generation of test cases for web service Application Programming Interfaces (APIs), the system comprising:

a memory storing instructions;

one or more Input/Output (I/O) interfaces; and

one or more hardware processors coupled to the memory via the one or more I/O interfaces, wherein the one or more hardware processors are configured by the instructions to:

receive a web application comprising a plurality of web service APIs;

identify a plurality of resource classes corresponding to each of the plurality of web service APIs by an instance of a forwarder using API related annotations present in a code of a package specified in the instance of the forwarder, wherein the forwarder is a library integrated with the web application, and wherein the API related annotations indicate that a class following an annotation is a resource class;

extract metadata related to each of the plurality of web service APIs from the plurality of resource classes by the instance of the forwarder using reflection libraries, wherein the extracted metadata for each of the plurality of web service APIs comprises at least one of (i) a Uniform Resource Identifier (URI), (ii) an HTTP Method, (iii) path variables, (iv) headers, (v) request parameters, (vi) a request body structure and (vii) a response body structure identified from built-in annotations in a code of the corresponding resource class, and (viii) sequence of call, (ix) method of authentication and (x) special field constraints identified from ApiInfo annotation and AttributeInfo annotation provided by a developer in a code of corresponding resource class, wherein the extracting comprises:

scanning the plurality of identified resource classes observed for a plurality of API related annotations in the code of the identified resource classes, wherein an object parser utility of the instance of the forwarder aids in scanning the plurality of identified resource classes; and

extracting the metadata from the plurality of API related annotations;

forward the extracted metadata to a test engine server to store in a database;

and

collect the extracted metadata from the database, by the test engine server to generate a plurality of test cases as a plurality of web service objects, the plurality of webservice objects acting as request payloads to the plurality of web service APIs in the resource classes, wherein each of the plurality of test cases are generated by the test engine server as an HTTP request comprising the path variables, the request parameters, the request body, a Uniform Resource Locator, URL, derived from the URL, the authentication method, the headers and the HTTP method based on the extracted metadata, wherein the test cases are generated for the web service APIs according to the sequence of call, and the request fields are filled based on the special field constraints.

5. The system of claim 4 , wherein the ApiInfo annotation and the AttributeInfo annotation are additional annotations made available for a developer to refine the test cases.

6. The system of claim 5 , wherein the ApiInfo annotation comprises sequence attribute which indicates sequence of call of the web service APIs, various a plurality of authentication related attributes and wherein the AttributeInfo annotation comprises a plurality of attributes which facilitate creation of the test cases.

7. One or more non-transitory machine-readable information storage mediums comprising one or more instructions, which when executed by one or more hardware processors causes:

receiving, by the one or more hardware processors, a web application comprising a plurality of web service APIs;

identifying, by the one or more hardware processors, a plurality of resource classes corresponding to each of the plurality of web service APIs by an instance of a forwarder using API related annotations present in a code of a package specified in the instance of the forwarder, wherein the forwarder is a library integrated with the web application, and wherein the API related annotations indicate that a class following an annotation is a resource class;

extracting, by the one or more hardware processors, metadata related to each of the plurality of web service APIs from the plurality of resource classes by the instance of the forwarder using reflection libraries, wherein the extracted metadata for each of the plurality of web service APIs comprises at least one of (i) a Uniform Resource Identifier (URI), (ii) an HTTP Method, (iii) path variables, (iv) headers, (v) request parameters, (vi) a request body structure and (vii) a response body structure identified from built-in annotations in a code of the corresponding resource class, (viii) sequence of call, (ix) method of authentication and (x) special field constraints identified from ApiInfo annotation and AttributeInfo annotation provided by a developer in a code of corresponding resource class, wherein the extracting comprises:

scanning, by the one or more hardware processors, the plurality of identified resource classes observed for a plurality of API related annotations in the code of the identified resource classes, and scanning the plurality of identified resource classes by an object parser utility of the instance of the forwarder; and

extracting the metadata from the plurality of API related annotations;

forwarding, by the one or more hardware processors, the extracted metadata to a test engine server to store in a database;

and

collecting, by the test engine server, the extracted metadata from the database and generate a plurality of test cases as a plurality of web service objects, the plurality of web service objects acting as request payloads to the plurality of web service APIs in the resource classes, wherein each of the plurality of test cases are generated by the test engine server as an HTTP request comprising the path variables, the request parameters, the request body, a Uniform Resource Locator, URL, derived from the URL, the authentication method, the headers and the HTTP method based on the extracted metadata, wherein the test cases are generated for the web service APIs according to the sequence of call, and the request fields are filled based on the special field constraints.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 23, 2021
From: TIWARI, ASHISH MANI; SHARMA, BRIJENDRA
To: TATA CONSULTANCY SERVICES LIMITED
Reel/Frame 057575/0723 →
Priority Claims (1)
IN 202021042302 · Sep 29, 2020 · national
Continuity (1)
Related Publication 20220100644A1 · Mar 31, 2022
Cited By (1)
US 12,657,118