How well are regular expressions tested in the wild?

How well are regular expressions tested in the wild?
复制标题

DOI:
10.1145/3236024.3236072
复制
发表时间:
2018-10
期刊:
Proceedings of the 2018 26th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering
影响因子:
--
通讯作者:
Peipei Wang;Kathryn T. Stolee
Peipei Wang;Kathryn T. Stolee
中科院分区:
其他
文献类型:
--
作者:
Peipei Wang;Kathryn T. Stolee

文献摘要

被引文献

相似文献

开发人员报告说,他们测试正则表达式的次数比测试其他代码的次数少。在这项工作中,我们将通过检查开源项目来探索正则表达式是如何经过彻底测试的。使用覆盖率的标准度量,比如行和分支覆盖率,给出了正则表达式测试覆盖率的不完整的图像。我们采用基于图的覆盖度量的DFA表示的正则表达式,提供细粒度的测试覆盖度量。使用GitHub上1,225个Java项目中超过15,000个经过测试的正则表达式,我们测量了节点、边和边对的覆盖率。我们的结果表明,只有17%的正则表达式在仓库中进行了测试。对于那些被测试的,测试输入的中位数是2。对于近42%的测试正则表达式,只使用一个测试输入。测试正则表达式的DFA上的平均节点和边缘覆盖水平分别为59%和29%。由于缺乏测试的正则表达式,我们探讨是否字符串生成工具的正则表达式,雷克斯,实现高覆盖率。除了一些例外,我们发现像雷克斯这样的工具可以用来编写覆盖率与开发人员测试相似的测试输入。
Developers report testing their regular expressions less than the rest of their code. In this work, we explore how thoroughly tested regular expressions are by examining open source projects. Using standard metrics of coverage, such as line and branch coverage, gives an incomplete picture of the test coverage of regular expressions. We adopt graph-based coverage metrics for the DFA representation of regular expressions, providing fine-grained test coverage metrics. Using over 15,000 tested regular expressions in 1,225 Java projects on GitHub, we measure node, edge, and edge-pair coverage. Our results show that only 17% of the regular expressions in the repositories are tested at all. For those that are tested, the median number of test inputs is two. For nearly 42% of the tested regular expressions, only one test input is used. Average node and edge coverage levels on the DFAs for tested regular expressions are 59% and 29%, respectively. Due to the lack of testing of regular expressions, we explore whether a string generation tool for regular expressions, Rex, achieves high coverage levels. With some exceptions, we found that tools such as Rex can be used to write test inputs with similar coverage to the developer tests.