Automatic Test Generation for Microservices Based on Consumer-Driven Contracts
Keywords:
Microservices, Testing, Consumer Driven Contract Testing, Test Generation, Mutation TestingSynopsis
This is a Chapter in:
Book:
Intelligent Computing and Consumer Support Applications
Series:
Chronicle of Computing
Chapter Abstract:
Microservices offer a shorter time-to-market by improving productivity with maximizing the automation of the software development lifecycle. However, when dealing with such systems, there are important design principles like their solidness and test coverage, which should be considered to be able to co-operate well in a distributed environment especially from the architecture level. However, for the provider of a service, it might be challenging to maintain the obligations needed by the consumer. Therefore, in this approach a form of agreement is written by the consumer of the service, which is called contract. In this paper, a language agnostic, no-code approach is proposed for conducting the consumer-driven contract concept, through automatically converting the contracts into a set of solid test suites, that runs on each deployment. Consequently, if the service provider alters the returned data in a way that breaks the expectations of the consumer, this breaking change will be detected early by running the auto-generated test suites. The proposed approach also provides an insight for the provider, on how their service is being used and how changes can affect the consumers. Then it gets evaluated with a dataset of 56 open-source projects available on Github which use consumer-driven contract testing. The results demonstrate that for 56 real source projects, the proposed approach has been able to generate 450 tests from the contract files in the sources and 90% of the generated test suites passed.
Keywords:
Software Engineering, Microservices, Testing, Consumer Driven Contract Testing, Test Generation, Mutation Testing, Software Development, Distributed Environments
Cite this paper as:
Zahedi S., Paydar S. (2023) Automatic Test Generation for Microservices Based on Consumer-Driven Contracts. In: Tiako P.F. (ed) Intelligent Computing and Consumer Support Applications. Chronicle of Computing. OkIP. https://doi.org/10.55432/978-1-6692-0003-1_5
Presented at:
The 2022 OkIP International Conference on Software Engineering Research & Development (SERD) in Oklahoma City, Oklahoma, USA, and Online, on October 3-6, 2022
Contacts:
Shaheen Zahedi
sh.zahedi@mail.um.ac.ir
Samad Paydar
s.paydar@um.ac.ir
References
Alessandro Viola Pizzoleto, F. C. (2019). A Systematic Literature Review of Techniques and Metrics to Reduce the Cost of Mutation Testing. The Journal of Systems & Software.
Alex Soto Bueno, A. G. (2019). Testing Java Microservices. New York: Manning.
Alex Soto Bueno, A. G. (2020 , April 06). How to Test Java Microservices with Pact. Retrieved from https://blogs.oracle.com/javamagazine/post/how-to-test-java-microservices-with-pact
Cristian Mart´ınez Hern´andez, A. M.-L. (2021). Comparison of End-to-End Testing Tools for Microservices: A Case Study. Information Technology and Systems, 1.
Fowler, M. (2006, June 12). Consumer-Driven Contracts: A Service Evolution Pattern. Retrieved from https://martinfowler.com/articles/consumerDrivenContracts.html
Fowler, M. (2012, May 1). TestPyramid. Retrieved from https://martinfowler.com/bliki/TestPyramid.html
Google, M. W. (2015, April 22). Just Say No to More End-to-End Tests. Retrieved from https://martinfowler.com/bliki/ContractTest.html
Inc., P. (n.d.). Pact Documentation. Retrieved from https://docs.pact.io/
Jacob Krüger, M. A.‐H. (2018). Mutation operators for feature‐oriented software product lines. Software: Testing, Verification and Reliability, 29(1-2), 21.
Kohei Arai, S. K. (2021). On Testing Microservice Systems. Proceedings of the Future Technologies Conference (FTC) 2020, Volume 3.
Lehvä, J., Mäkitalo, N., & Mikkonen, T. (2019). Consumer-Driven Contract Tests for Microservices: A Case Study. Product-Focused Software Process Improvement : 20th International Conference. Barcelona, Spain.
Meyer, B. (1992). Applying “Design by Contract'. Interactive Software Engineering, 25(10).
Muhammad Waseem, P. L. (2021). Design, monitoring, and testing of microservices systems: The practitioners’ perspective. The Journal of Systems & Software.
newman, S. (2014). Building Microservices desinging find grained systems. O'Reilly.
Spring. (2020). Spring Cloud Contract. (Sun Microsystems) Retrieved from https://spring.io/projects/spring-cloud-contract
Sriniketan Mysari, V. B. (2020). Continuous Integration And Continuous Deployment Pipeline Automation Using Jenkins Ansible. International Conference on Emerging Trends in Information Technology and Engineering (ic-ETITE). Engineering and Science.
Taibi, D., Lenarduzzi, V., & Pahl, C. (2017). Processes, Motivations, and Issues for Migrating to Microservices Architectures: An Empirical Investigation. IEEE Cloud Computing, 4(5), 1083 - 1099.
