一句话:提出首个支持 API 调用嵌套并测试异步回调的反馈导向单元测试生成器 Nessie。
现有反馈导向单元测试生成算法通过执行部分测试并在末尾追加 API 调用构造序列,但只支持调用排序;面对接收回调且回调常异步执行的高阶函数 API,无法将调用嵌套进回调,难以有效测试。本文提出 Nessie,首个支持 API 调用嵌套并测试异步回调的反馈导向单元测试生成器。其核心是带回调单元测试的树表示和迭代生成此类测试的反馈导向算法。在十个流行 JavaScript 库(含同步与异步回调)上,与仅考虑方法调用排序的 LambdaTester 相比,Nessie 发现更多行为差异,覆盖率略高,且达到并超过该覆盖率所需测试数显著更少。
Previous algorithms for feedback-directed unit test generation iteratively create sequences of API calls by executing partial tests and by adding new API calls at the end of the test. These algorithms are challenged by a popular class of APIs: higher-order functions that receive callback arguments, which often are invoked asyn-chronously. Existing test generators cannot effectively test such APIs because they only sequence API calls, but do not nest one call into the callback function of another. This paper presents Nessie, the first feedback-directed unit test generator that supports nesting of API calls and that tests asynchronous callbacks. Nesting API calls enables a test to use values produced by an API that are available only once a callback has been invoked, and is often necessary to ensure that methods are invoked in a specific order. The core contributions of our approach are a tree-based representation of unit tests with callbacks and a novel algorithm to iteratively generate such tests in a feedback-directed manner. We evaluate our approach on ten popular JavaScript libraries with both asynchronous and synchronous callbacks. The results show that, in a comparison with LambdaTester, a state of the art test generation technique that only considers sequencing of method calls, Nessie finds more behavioral differences and achieves slightly higher coverage. Notably, Nessie needs to generate significantly fewer tests to achieve and exceed the coverage achieved by the state of the art.