Modern software is increasingly built by composing APIs, elevating the API contract to a critical role. Inadequate contracts, however, lead to mismatched expectations and failures, creating a pressing need for robust conformance testing. Current test generation techniques are hindered by key challenges: polyglot systems, source code inaccessibility, a cost-reliability trade-off, and, most critically, the difficulty of generating structured inputs. We introduce BOSQTGEN, a novel black-box methodology and tool for API test generation. BOSQTGEN utilizes a novel approach for decomposing API specifications into primitives, using LLMs to suggest coherent strata for them, and employing combinatorial testing to efficiently sample over these values. This approach ensures coverage of critical interactions while avoiding the redundancy of random sampling. The resulting BOSQTGEN system achieves an average of 82% code coverage on RESTful benchmarks, often a 20% or more increase over prior state-of-the-art systems and nearing parity with hand-written test suites. Providing a fully API-driven approach to test generation, enables developers to automatically create high-quality test cases for validation or test-driven development.
翻译:现代软件越来越多地通过组合API来构建,这使得API契约提升到了一个至关重要的角色。然而,不充分的契约会导致期望不匹配和故障,从而产生了对健壮一致性测试的迫切需求。当前的测试生成技术受到几个关键挑战的阻碍:多语言系统、源代码不可访问性、成本与可靠性的权衡,以及最关键的结构化输入生成难题。我们提出了BOSQTGEN,一种新颖的用于API测试生成的黑盒方法及工具。BOSQTGEN采用了一种新颖的方法,将API规范分解为基本单元,利用LLM为这些单元建议连贯的层次结构,并采用组合测试来高效地对这些值进行采样。这种方法确保了关键交互的覆盖,同时避免了随机采样的冗余。最终的BOSQTGEN系统在RESTful基准测试上平均实现了82%的代码覆盖率,通常比先前最先进的系统提高了20%或更多,并接近手工编写的测试套件的水平。通过提供一种完全API驱动的测试生成方法,使开发人员能够自动创建高质量的测试用例,用于验证或测试驱动开发。