arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2408.08594cs.SE
收藏

DeepREST:利用深度强化学习的REST API自动化测试用例生成

DeepREST: Automated Test Case Generation for REST APIs Exploiting Deep Reinforcement Learning

Davide Corradini, Zeno Montolli, Michele Pasqua, Mariano Ceccato

AI总结:

针对现有REST API黑盒测试依赖OAS文档、缺乏业务逻辑语义导致测试用例有效性不足的问题,提出基于深度强化学习的DeepREST方法,通过好奇心驱动探索隐式约束、利用成功交互生成输入、变异交互提升覆盖,实现更高的测试覆盖率与故障检测能力。

摘要:

为REST API自动设计测试场景有助于构建更可靠、更可信的面向Web的系统。然而,当前的黑盒测试方法高度依赖API正式文档(即OpenAPI Specification,简称OAS)中可用的信息。OAS虽然有用,但大多只覆盖API的语法层面(例如操作之间的生产者-消费者关系、输入值属性,以及自然语言描述的额外约束),缺乏对API业务逻辑的更深层理解。缺失的语义包括操作之间的隐式排序(逻辑依赖)和隐式输入值约束。这些局限性阻碍了黑盒测试工具自动生成真正有效测试用例的能力。\n本文提出DeepREST,一种用于REST API自动化测试的新型黑盒方法。它利用深度强化学习挖掘隐式API约束,即API文档中未提及的隐藏约束。好奇心驱动的学习引导智能体探索API,并学习测试其操作的有效顺序。这有助于确定应优先测试哪些操作,使API进入可测试状态,避免后续API交互失败。同时,利用成功API交互中积累的经验来驱动精准的输入数据生成(即使用哪些参数以及如何选取参数值)。此外,DeepREST通过对成功的API交互进行变异,在探索与利用之间交替切换,以提升测试覆盖率并收集更多经验。我们的实证验证表明,所提方法在实现高测试覆盖率和故障检测方面非常有效,且优于现有最优基线方法。

英文摘要:

Automatically crafting test scenarios for REST APIs helps deliver more reliable and trustworthy web-oriented systems. However, current black-box testing approaches rely heavily on the information available in the API's formal documentation, i.e., the OpenAPI Specification (OAS for short). While useful, the OAS mostly covers syntactic aspects of the API (e.g., producer-consumer relations between operations, input value properties, and additional constraints in natural language), and it lacks a deeper understanding of the API business logic. Missing semantics include implicit ordering (logic dependency) between operations and implicit input-value constraints. These limitations hinder the ability of black-box testing tools to generate truly effective test cases automatically. This paper introduces DeepREST, a novel black-box approach for automatically testing REST APIs. It leverages deep reinforcement learning to uncover implicit API constraints, that is, constraints hidden from API documentation. Curiosity-driven learning guides an agent in the exploration of the API and learns an effective order to test its operations. This helps identify which operations to test first to take the API in a testable state and avoid failing API interactions later. At the same time, experience gained on successful API interactions is leveraged to drive accurate input data generation (i.e., what parameters to use and how to pick their values). Additionally, DeepREST alternates exploration with exploitation by mutating successful API interactions to improve test coverage and collect further experience. Our empirical validation suggests that the proposed approach is very effective in achieving high test coverage and fault detection and superior to a state-of-the-art baseline.

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

↑