GraphQL is a new paradigm to design web APIs. Despite its growing popularity, there are few techniques to verify the implementation of a GraphQL API. We present a new testing approach based on GraphQL queries that are logged while users interact with an application in production. Our core motivation is that production queries capture real usages of the application, and are known to trigger behavior that may not be tested by developers. For each logged query, a test is generated to assert the validity of the GraphQL response with respect to the schema. We implement our approach in a tool called AutoGraphQL, and evaluate it on two real-world case studies that are diverse in their domain and technology stack: an open-source e-commerce application implemented in Python called Saleor, and an industrial case study which is a PHP-based finance website called Frontapp. AutoGraphQL successfully generates test cases for the two applications. The generated tests cover 26.9% of the Saleor schema, including parts of the API not exercised by the original test suite, as well as 48.7% of the Frontapp schema, detecting 8 schema faults, thanks to production queries.
翻译:图形QL 是设计网络 API 的新范例 。 尽管它越来越受欢迎, 很少有技术来验证 图形QL API 的实施 。 我们展示了一种基于 GraphQL 查询的新测试方法, 在用户与生产应用程序互动时, 以图形QL 查询记录下来。 我们的核心动机是, 生产查询能够捕捉应用程序的真实用途, 并已知会引发开发者无法测试的行为 。 对于每个登录查询, 都会产生一个测试, 以确认图形QL 回应对 schema 的正确性 。 我们用一个名为 AutoGraph QL 的工具执行我们的方法, 并评估两个真实世界的案例研究, 这些案例研究在其域和技术堆中是多种多样的: 在Python 称作 Saleler 的 Python 中实施了一个开放源的电子商务应用程序, 以及一个工业案例研究, 是一个基于 PHPHP 的金融网站, 名为 Frontap 。 AutGraphQL 成功生成了两个应用程序的测试案例。 。 。 测试覆盖了 Salemor schema 的26.9 %,, 包括未由原测试套件所操作所操作的部分, 还有48.