Best testing practices state that tests should verify a single functionality or behavior of the system. Tests that verify multiple behaviors are harder to understand, lack focus, and are more coupled to the production code. An attempt to identify this issue is the test smell \emph{Eager Test}, which aims to capture tests that verify too much functionality based on the number of production method calls. Unfortunately, prior research suggests that counting production method calls is an inaccurate measure, as these calls do not reliably serve as a proxy for functionality. We envision a complementary solution based on runtime analysis: we hypothesize that some tests that verify multiple behaviors will likely cover multiple paths of the same production methods. Thus, we propose a novel test smell named \emph{Test Obsessed by Method}, a test method that covers multiple paths of a single production method. We provide an initial empirical study to explore the presence of this smell in 2,054 tests provided by 12 test suites of the Python Standard Library. (1) We detect 44 \emph{Tests Obsessed by Methods} in 11 of the 12 test suites. (2) Each smelly test verifies a median of two behaviors of the production method. (3) The 44 smelly tests could be split into 118 novel tests. (4) 23% of the smelly tests have code comments recognizing that distinct behaviors are being tested. We conclude by discussing benefits, limitations, and further research.


翻译:最佳测试实践指出,测试应验证系统的单一功能或行为。验证多个行为的测试更难理解、缺乏重点,且与生产代码的耦合度更高。识别此问题的一种尝试是测试坏味道“贪婪测试”,其旨在基于生产方法调用次数来捕获验证过多功能的测试。然而,先前研究表明,统计生产方法调用次数是一种不准确的度量方式,因为这些调用并不能可靠地作为功能的代理指标。我们设想一种基于运行时分析的补充解决方案:我们假设某些验证多个行为的测试很可能覆盖同一生产方法的多个执行路径。因此,我们提出一种名为“方法沉迷测试”的新型测试坏味道,即覆盖单个生产方法多个执行路径的测试方法。我们通过一项初步实证研究,在Python标准库的12个测试套件提供的2,054个测试中探索该坏味道的存在情况。(1) 我们在12个测试套件中的11个里检测到44个“方法沉迷测试”。(2) 每个存在坏味道的测试平均验证生产方法的两个行为。(3) 这44个存在坏味道的测试可拆分为118个新测试。(4) 23%的存在坏味道的测试带有代码注释,表明其正在测试不同的行为。最后,我们讨论了该方法的优势、局限性与未来研究方向。

0
下载
关闭预览

相关内容

《学习型系统的测试与评估》
专知会员服务
60+阅读 · 2023年3月12日
索邦大学121页博士论文《时间序列中的无监督异常检测》
专知会员服务
103+阅读 · 2022年7月25日
WSDM'22「百度」考虑行为多样性的对比元学习
专知会员服务
24+阅读 · 2022年2月21日
深度学习目标检测方法综述
专知会员服务
280+阅读 · 2020年8月1日
异常检测(Anomaly Detection)综述
极市平台
20+阅读 · 2020年10月24日
异常检测论文大列表:方法、应用、综述
专知
126+阅读 · 2019年7月15日
从传统方法到深度学习,人脸关键点检测方法综述
机器之心
14+阅读 · 2017年12月17日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2017年12月31日
国家自然科学基金
43+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
10+阅读 · 2013年12月31日
Arxiv
0+阅读 · 2月5日
Arxiv
0+阅读 · 1月22日
VIP会员
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2017年12月31日
国家自然科学基金
43+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
10+阅读 · 2013年12月31日
Top
微信扫码咨询专知VIP会员