arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2305.14692cs.SE
收藏

切分UI测试以生成API测试和API规范

Carving UI Tests to Generate API Tests and API Specification

Rahulkrishna Yandrapally, Saurabh Sinha, Rachel Tzoref-Brill, Ali Mesbah

AI总结:

提出一种利用UI测试导航和定向API探测动态推断API端点的方法,自动生成API测试套件和OpenAPI规范,在现有工具不适用时实现高效的API级测试并显著提升代码覆盖率。

摘要:

现代Web应用程序广泛使用API调用来更新UI状态,以响应用户事件或服务器端的变化。对于此类应用程序,API级别测试可以在单元级测试和UI级(或端到端)测试之间发挥重要作用。现有的API测试工具需要API规范(例如OpenAPI),这些规范通常可能不可用,或者在可用时与API实现不一致,从而限制了自动化API测试在Web应用程序中的适用性。在本文中,我们提出了一种利用UI测试来为Web应用程序启用API级测试的方法。我们的技术导航被测Web应用程序,并自动生成API级测试套件,以及描述应用程序服务器端API的OpenAPI规范(适用于基于REST的Web应用程序)。我们解决方案的一个关键要素是一种动态方法,通过UI导航和定向API探测来推断带有路径参数的API端点。我们评估了该技术在推断API规范方面的准确性以及“切分”出的API测试的有效性。我们在七个开源Web应用程序上的结果显示,该技术在推断端点方面达到了98%的精确率和56%的召回率。将切分出的API测试添加到两个自动化REST API测试工具生成的测试套件中,平均使语句覆盖率提高了52%和29%,分支覆盖率提高了99%和75%。我们技术的主要优势是:(1)它在现有API测试工具不适用的情况下,能够对Web应用程序进行API级测试;(2)它创建的API级测试套件能够高效覆盖服务器端代码,同时像从应用程序的Web UI调用那样执行API,并且能够增强现有的API测试套件。

英文摘要:

Modern web applications make extensive use of API calls to update the UI state in response to user events or server-side changes. For such applications, API-level testing can play an important role, in-between unit-level testing and UI-level (or end-to-end) testing. Existing API testing tools require API specifications (e.g., OpenAPI), which often may not be available or, when available, be inconsistent with the API implementation, thus limiting the applicability of automated API testing to web applications. In this paper, we present an approach that leverages UI testing to enable API-level testing for web applications. Our technique navigates the web application under test and automatically generates an API-level test suite, along with an OpenAPI specification that describes the application's server-side APIs (for REST-based web applications). A key element of our solution is a dynamic approach for inferring API endpoints with path parameters via UI navigation and directed API probing. We evaluated the technique for its accuracy in inferring API specifications and the effectiveness of the "carved" API tests. Our results on seven open-source web applications show that the technique achieves 98% precision and 56% recall in inferring endpoints. The carved API tests, when added to test suites generated by two automated REST API testing tools, increase statement coverage by 52% and 29% and branch coverage by 99% and 75%, on average. The main benefits of our technique are: (1) it enables API-level testing of web applications in cases where existing API testing tools are inapplicable and (2) it creates API-level test suites that cover server-side code efficiently while exercising APIs as they would be invoked from an application's web UI, and that can augment existing API test suites.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑