检测与评估 JavaScript 中的顺序依赖型不稳定测试
Detecting and Evaluating Order-Dependent Flaky Tests in JavaScript
AI总结:
本文针对 JavaScript 项目中 Jest 测试框架的顺序依赖型不稳定测试,提出系统化随机化重排检测方法,在 81 个项目中识别出 55 个顺序依赖型测试,并发现共享模拟状态这一新成因。
摘要:
不稳定测试对软件测试构成重大问题。具有非确定性结果的测试可能削弱测试过程的可靠性,使测试变得不可信。先前的研究已确定测试顺序依赖是导致不稳定性的最常见原因之一,尤其是在 Java 和 Python 中。然而,关于 JavaScript 测试中的测试顺序依赖知之甚少。本文旨在研究使用 Jest(一种广泛使用的 JavaScript 测试框架)的 JavaScript 项目中的测试顺序依赖。我们实现了一种系统化的方法来随机化测试、测试套件和 describe 块,并为每个级别生成了 10 种独特的测试重排序。我们对每种顺序重跑了 10 次(每个测试套件/项目共 100 次重跑),并记录了测试结果的任何变化。随后,我们手动分析了每个表现出不稳定结果的案例,以确定不稳定性的原因。我们在从 GitHub 获取的 81 个项目数据集上检验了我们的检测方法。我们的结果揭示了 10 个项目中的 55 个顺序依赖型测试。大多数顺序依赖型测试(52 个)发生在测试之间,而其余 3 个发生在 describe 块之间。这些顺序依赖型测试是由测试之间的共享文件(13 个)或共享模拟状态(42 个)引起的。虽然共享文件在其他语言中是顺序依赖型测试的已知原因,但我们的结果强调了一种先前未被报告的新原因(共享模拟状态)。
英文摘要:
Flaky tests pose a significant issue for software testing. A test with a non-deterministic outcome may undermine the reliability of the testing process, making tests untrustworthy. Previous research has identified test order dependency as one of the most prevalent causes of flakiness, particularly in Java and Python. However, little is known about test order dependency in JavaScript tests. This paper aims to investigate test order dependency in JavaScript projects that use Jest, a widely used JavaScript testing framework. We implemented a systematic approach to randomise tests, test suites and describe blocks and produced 10 unique test reorders for each level. We reran each order 10 times (100 reruns for each test suite/project) and recorded any changes in test outcomes. We then manually analysed each case that showed flaky outcomes to determine the cause of flakiness. We examined our detection approach on a dataset of 81 projects obtained from GitHub. Our results revealed 55 order-dependent tests across 10 projects. Most order-dependent tests (52) occurred between tests, while the remaining three occurred between describe blocks. Those order-dependent tests are caused by either shared files (13) or shared mocking state (42) between tests. While sharing files is a known cause of order-dependent tests in other languages, our results underline a new cause (shared mocking state) that was not reported previously
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。