一句话:首次大规模实证分析 R 包单元测试质量、测试技术债来源及开发者面临的挑战。
本文研究 R 包生态中的测试技术债(TTD)问题:由于 R 包被广泛复用,其测试缺陷会沿依赖关系传递,威胁依赖它的分析有效性,但此前缺乏对 R 包单元测试实践的系统认识。作者采用两部分混合方法:首先系统选取并挖掘 177 个开源 R 包,分析测试质量、测试目标并识别潜在 TTD 来源;其次问卷调查 R 包开发者对测试的看法与挑战,回复率为 19.4%。结果表明 R 包测试质量偏低,常见测试坏味包括不充分且晦涩的单元测试、不当断言、缺乏经验的测试者和不当测试设计;即使熟练开发者仍受时间约束、重开发轻测试、工具文档不足和学习曲线陡峭等问题困扰。
Testing Technical Debt (TTD) occurs due to shortcuts (non-optimal decisions) taken about testing; it is the test dimension of technical debt. R is a package-based programming ecosystem that provides an easy way to install third-party code, datasets, tests, documentation and examples. This structure makes it especially vulnerable to TTD because errors present in a package can transitively affect all packages and scripts that depend on it. Thus, TTD can effectively become a threat to the validity of all analysis written in R that rely on potentially faulty code. This two-part study provides the first analysis in this area. First, 177 systematically-selected, open-source R packages were mined and analysed to address quality of testing, testing goals, and identify potential TTD sources. Second, a survey addressed how R package developers perceive testing and face its challenges (response rate of 19.4%). Results show that testing in R packages is of low quality; the most common smells are inadequate and obscure unit testing, improper asserts, inexperienced testers and improper test design. Furthermore, skilled R developers still face challenges such as time constraints, emphasis on development rather than testing, poor tool documentation and a steep learning curve.