Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2021 Aug 9;21(16):5375.
doi: 10.3390/s21165375.

Automated Specification-Based Testing of REST APIs

Affiliations

Automated Specification-Based Testing of REST APIs

Ovidiu Baniaș et al. Sensors (Basel). .

Abstract

Nowadays, REpresentational State Transfer Application Programming Interfaces (REST APIs) are widely used in web applications, hence a plethora of test cases are developed to validate the APIs calls. We propose a solution that automates the generation of test cases for REST APIs based on their specifications. In our approach, apart from the automatic generation of test cases, we provide an option for the user to influence the test case generation process. By adding user interaction, we aim to augment the automatic generation of APIs test cases with human testing expertise and specific context. We use the latest version of OpenAPI 3.x and a wide range of coverage metrics to analyze the functionality and performance of the generated test cases, and non-functional metrics to analyze the performance of the APIs. The experiments proved the effectiveness and practicability of our method.

Keywords: OpenAPI 3.x; REST API; automatic test case generation; software testing; specification-based testing.

PubMed Disclaimer

Conflict of interest statement

The authors declare no conflict of interest.

Figures

Figure 1
Figure 1
Applicability of REST API.
Figure 2
Figure 2
Test Coverage Model: Levels and Criteria [7].
Figure 3
Figure 3
System activities and actions (activity diagram).
Figure 4
Figure 4
Descriptive values for API parameters.
Figure 5
Figure 5
User input dialog example.
Figure 6
Figure 6
Structural description of the system (class diagram).
Figure 7
Figure 7
Path coverage.
Figure 8
Figure 8
Operation coverage.
Figure 9
Figure 9
Paths tested.
Figure 10
Figure 10
Operations tested.
Figure 11
Figure 11
Parameter coverage.
Figure 12
Figure 12
Status code coverage.
Figure 13
Figure 13
Content type coverage.
Figure 14
Figure 14
Response body property coverage.
Figure 15
Figure 15
Performance metric.
Figure 16
Figure 16
Overview statistics.

References

    1. Neumann A., Laranjeiro N., Bernardino J. An Analysis of Public REST Web Service APIs. IEEE Trans. Serv. Comput. 2018;14:957–970. doi: 10.1109/TSC.2018.2847344. - DOI
    1. Toman S.H. Review of Web Service Technologies: REST over SOAP. J. Al-Qadisiyah Comput. Sci. Math. 2020;12:18–30.
    1. Bülthoff F., Maleshkova M. Lecture Notes in Computer Science, Proceedings of the Semantic Web: ESWC 2014 Satellite Events, Crete, Greece, 25–29 May 2014. Springer; Cham, Switzerland: 2014. RESTful or RESTless—Current State of Today’s Top Web APIs; pp. 64–74.
    1. Ed-douibi H., Izquierdo J.L.C., Cabot J. Automatic Generation of Test Cases for REST APIs: A Specification-Based Approach; Proceedings of the 2018 IEEE 22nd International Enterprise Distributed Object Computing Conference; Stockholm, Sweden. 16–19 October 2018; Barcelona, Spain: Universitat Oberta de Catalunya; 2018.
    1. Karlsson A. Ph.D. Thesis. Linköping University; Linköping, Switzerland: 2020. Automatic Test Generation of REST API.

LinkOut - more resources