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

通过基于规范的测试发现bug很容易!

Finding Bugs with Specification-Based Testing is Easy!

Janice Chin, David Pearce

摘要:

基于规格的自动化测试有着悠久的历史,出现了几个著名的工具。例如,QuickCheck for Haskell专注于针对用户提供的属性进行测试。其他的,比如JMLUnit,使用前置和后置条件形式的规范来驱动测试。一个有趣的(也是未被探索的)问题是,这种方法在实际中发现bug的效率如何。一般来说,人们会认为自动化测试在发现bug方面不如静态验证有效。但是,效果差多少呢?为了阐明这个问题,我们考虑用Whiley编写的程序的自动化测试--Whiley是一种对规范具有一流支持的语言。虽然最初设计时考虑到了静态验证,但我们发现Whiley的自动化测试令人惊讶地有用且具有成本效益。例如,当自动化测试检测到错误时,总是提供一个反例。这促使本文提出了更严格的实证检验。为此,我们为Whiley提供了一个自动化测试工具背后的实现技术讨论。在这里,一个关键的可用性问题是参数化输入空间的能力,我们提出了新的方法,为参考和参考。然后,我们报告了几项大型实验,使用一系列基准测试(包括一套1800多个突变体)来调查该工具在发现错误方面的有效性。结果表明,自动化测试在许多情况下是有效的,抽样提供了有用的性能优势,只有适度的减少缺陷发现能力。最后,我们报告了该工具的一些实际使用情况,在这些情况下,它被证明在查找bug方面是有效的(例如在标准库中)。

英文摘要:

Automated specification-based testing has a long history with several notable tools having emerged. For example, QuickCheck for Haskell focuses on testing against user-provided properties. Others, such as JMLUnit, use specifications in the form of pre- and post-conditions to drive testing. An interesting (and under-explored) question is how effective this approach is at finding bugs in practice. In general, one would assume automated testing is less effective at bug finding than static verification. But, how much less effective? To shed light on this question, we consider automated testing of programs written in Whiley -- a language with first-class support for specifications. Whilst originally designed with static verification in mind, we have anecdotally found automated testing for Whiley surprisingly useful and cost-effective. For example, when an error is detected with automated testing, a counterexample is always provided. This has motivated the more rigorous empirical examination presented in this paper. To that end, we provide a technical discussion of the implementation behind an automated testing tool for Whiley. Here, a key usability concern is the ability to parameterise the input space, and we present novel approaches for references and lambdas. We then report on several large experiments investigating the tool's effectiveness at bug finding using a range of benchmarks, including a suite of 1800+ mutants. The results indicate the automated testing is effective in many cases, and that sampling offers useful performance benefits with only modest reductions in bug-finding capability. Finally, we report on some real-world uses of the tool where it has proved effective at finding bugs (such as in the standard library).

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

↑