Automatic Test Generation for Microservices Based on Consumer-Driven Contracts
Shaheen Zahedi, Samad Paydar · Chronicle of computing · 2023
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.