Skip to main content
QUICK REVIEW

[论文解读] Concurrency-related Flaky Test Detection in Android apps

Zhen Dong, Abhishek Tiwari|arXiv (Cornell University)|May 21, 2020
Software Testing and Debugging Techniques参考文献 27被引用 11
一句话总结

本论文提出 FlakeScanner,一种通过系统性地探索 UI 线程与后台线程之间的可行事件执行顺序,主动检测 Android 应用中与并发相关的 flaky 测试的工具。通过分析事件调度边界并按语句分组事件,FlakeScanner 能够识别出即使在通过测试中也存在 flaky 行为的测试,其在 FlakyAppRepo 套件上的表现证明了其高效率,该套件发现了 245 个此前未知的 flaky 测试。

ABSTRACT

Validation of Android apps via testing is difficult owing to the presence of flaky tests. Due to non-deterministic execution environments, a sequence of events (a test) may lead to success or failure in unpredictable ways. In this work, we present an approach and tool FlakeShovel for detecting flaky tests through systematic exploration of event orders. Our key observation is that for a test in a mobile app, there is a testing framework thread which creates the test events, a main User-Interface (UI) thread processing these events, and there may be several other background threads running asynchronously. For any event e whose execution involves potential non-determinism, we localize the earliest (latest) event after (before) which e must happen.We then efficiently explore the schedules between the upper/lower bound events while grouping events within a single statement, to find whether the test outcome is flaky. We also create a suite of subject programs called DroidFlaker to study flaky tests in Android apps. Our experiments on subject-suite DroidFlaker demonstrate the efficacy of our flaky test detection. Our work is complementary to existing flaky test detection tools like Deflaker which check only failing tests. FlakeShovel can detect flaky tests among passing tests, as shown by our approach and experiments.

研究动机与目标

  • 为解决 Android GUI 测试中 flaky 测试这一关键问题,该问题会损害回归测试的可靠性并降低开发人员的生产力。
  • 主动检测 flaky 测试,包括那些在标准运行中通过但在某些非确定性执行顺序下会失败的测试。
  • 克服现有工具(如 DeFlaker)的局限性,后者仅分析失败的测试,因而会遗漏那些通过但实际是 flaky 的测试。
  • 构建一个全面的基准套件 FlakyAppRepo,用于研究真实世界 Android 应用中 flaky 测试的行为。
  • 提供一种动态的、系统级分析方法,精确捕捉事件依赖关系,避免因不完整的 happens-before 关系导致的误报。

提出的方法

  • FlakeScanner 建模 Android 的单个 UI 线程和异步后台线程,为每个测试事件确定其事件调度边界。
  • 对于存在潜在非确定性的每个事件,基于线程依赖关系计算其必须执行的最早和最晚事件(前后)。
  • 然后在这些边界内系统性地探索事件排序,并将来自同一语句的事件分组以减少状态空间。
  • 该工具使用动态分析来模拟不同的执行环境,并检测是否存在某种事件顺序会导致测试失败。
  • 它利用 Espresso 测试框架的事件队列语义来建模真实的线程交错和事件竞争。
  • 该方法辅以 FlakyAppRepo 的创建,这是一个精心挑选的 28 个流行 Android 应用的套件,平均每个应用拥有 2.5k 个 GitHub 星标,用于评估 flaky 测试检测效果。

实验结果

研究问题

  • RQ1一种主动检测方法能否识别出在标准运行中通过但在某些执行顺序下会失败的与并发相关的 flaky 测试?
  • RQ2与现有的重运行或基于覆盖率的方法相比,系统性探索事件排序在检测 flaky 测试方面的有效性如何?
  • RQ3在真实世界 Android 应用中,flaky 测试的普遍程度如何,特别是那些通过但仍然 flaky 的测试?
  • RQ4精确的事件依赖关系建模在多大程度上能减少 flaky 测试检测中的误报?
  • RQ5与 DeFlaker 和事件竞争检测器等现有工具相比,所提出方法在准确性和可扩展性方面表现如何?

主要发现

  • FlakeScanner 在 FlakyAppRepo 套件中成功检测到 245 个此前未被识别的新 flaky 测试,证明其能够发现隐藏的 flakiness。
  • 该工具在标准运行中通过的测试中也检测到了 flaky 测试,证明其具备超越现有仅分析失败测试工具的主动检测能力。
  • FlakyAppRepo 基准套件包含 28 个广泛使用的 Android 应用,平均每个应用拥有 2.5k 个 GitHub 星标,为研究 flaky 测试提供了真实且具有代表性的测试环境。
  • 研究证实,并发和异步等待是 flaky 测试的主要原因,与先前的经验发现一致。
  • FlakeScanner 采用动态分析并结合精确的事件依赖关系建模,相比依赖不完整 happens-before 关系的方法,显著减少了误报。
  • 结果表明,flaky 测试是一个普遍存在的问题——回归测试中 84% 的 pass-to-fail 转换是由 flaky 测试引起的,凸显了主动检测的必要性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。