Lune

ICSE2022Top-tier venue

Repairing Order-Dependent Flaky Tests via Test Generation

Chengpeng Li, Chenguang Zhu, Wenxi Wang, August Shi

Abstract

Flaky tests are tests that pass or fail nondeterministically on the same version of code. These tests can mislead developers concerning the quality of their code changes during regression testing. A common kind of flaky tests are order-dependent tests, whose pass/ fail outcomes depend on the test order in which they are run. Such tests have different outcomes because other tests running before them pollute shared state. Prior work has proposed repairing orderdependent tests by searching for existing tests, known as "cleaners", that reset the shared state, allowing the order-dependent test to pass when run after a polluted shared state. The code within a cleaner represents a patch to repair the order-dependent test. However, this technique requires cleaners to already exist in the test suite. We propose ODRepair, an automated technique to repair orderdependent tests even without existing cleaners. The idea is to first determine the exact polluted shared state that results in the orderdependent test to fail and then generate code that can modify and reset the shared state so that the order-dependent test can pass. We focus on shared state through internal heap memory, in particular shared state reachable from static fields. Once we know which static field leads to the pollution, we search for reset-methods in the codebase that can potentially access and modify state reachable from that static field. We then apply an automatic test-generation tool to generate method-call sequences, targeting these reset-methods. Our evaluation on 327 order-dependent tests from a publicly available dataset shows that ODRepair automatically identifies the polluted static field for 181 tests, and it can generate patches for 141 of these tests. Compared against state-of-the-art iFixFlakies, ODRepair can generate patches for 24 tests that iFixFlakies cannot.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

7 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Reducing Test Runtime by Transforming Test Fixtures cites Evolution-aware detection of order-dependent flaky tests
  • Reducing Test Runtime by Transforming Test Fixtures cites A large-scale longitudinal study of flaky tests
  • Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined Specifications cites A large-scale longitudinal study of flaky tests
  • FLEX: fixing flaky tests in machine learning projects by updating assertion bounds cites Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined Specifications
  • FLEX: fixing flaky tests in machine learning projects by updating assertion bounds cites Detecting flaky tests in probabilistic and machine learning applications
  • Evolution-aware detection of order-dependent flaky tests cites A large-scale longitudinal study of flaky tests
  • Evolution-aware detection of order-dependent flaky tests cites Detecting flaky tests in probabilistic and machine learning applications
  • Evolution-aware detection of order-dependent flaky tests cites Dependent-test-aware regression testing techniques
  • Ranking Relevant Tests for Order-Dependent Flaky Tests cites Evolution-aware detection of order-dependent flaky tests
  • Ranking Relevant Tests for Order-Dependent Flaky Tests cites A large-scale longitudinal study of flaky tests
  • Ranking Relevant Tests for Order-Dependent Flaky Tests cites Dependent-test-aware regression testing techniques
  • Preempting Flaky Tests via Non-Idempotent-Outcome Tests cites Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined Specifications
  • Preempting Flaky Tests via Non-Idempotent-Outcome Tests cites FLEX: fixing flaky tests in machine learning projects by updating assertion bounds
  • Preempting Flaky Tests via Non-Idempotent-Outcome Tests cites A large-scale longitudinal study of flaky tests
  • Preempting Flaky Tests via Non-Idempotent-Outcome Tests cites Detecting flaky tests in probabilistic and machine learning applications
  • Preempting Flaky Tests via Non-Idempotent-Outcome Tests cites Dependent-test-aware regression testing techniques
  • Do Automatic Test Generation Tools Generate Flaky Tests? cites Preempting Flaky Tests via Non-Idempotent-Outcome Tests
  • Do Automatic Test Generation Tools Generate Flaky Tests? cites Detecting flaky tests in probabilistic and machine learning applications
  • Do Automatic Test Generation Tools Generate Flaky Tests? cites Dependent-test-aware regression testing techniques
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers7

  1. Preempting Flaky Tests via Non-Idempotent-Outcome TestsAnjiang Wei, Pu Yi, Zhengxi Li, Tao Xie et al.ICSE 2022 · 20 citations
  2. Evolution-aware detection of order-dependent flaky testsChengpeng Li, August ShiISSTA 2022 · 12 citations
  3. Do Automatic Test Generation Tools Generate Flaky Tests?Martin Gruber, Muhammad Firhard Roslan, Owain Parry, Fabian Scharnböck et al.ICSE 2024 · 12 citations
  4. Reducing Test Runtime by Transforming Test FixturesChengpeng Li, Abdelrahman Baz, August ShiASE 2024 · 1 citation
  5. Ranking Relevant Tests for Order-Dependent Flaky TestsShanto Rahman, Bala Naren Chanumolu, Suzzana Rafi, August Shi et al.ICSE 2025 · 1 citation

Builds on6

  1. Detecting flaky tests in probabilistic and machine learning applicationsSaikat Dutta, August Shi, Rutvik Choudhary, Zhekun Zhang et al.ISSTA 2020 · 71 citations
  2. A large-scale longitudinal study of flaky testsWing Lam, Stefan Winter, Anjiang Wei, Tao Xie et al.OOPSLA 2020 · 63 citations
  3. Dependent-test-aware regression testing techniquesWing Lam, August Shi, Reed Oei, Sai Zhang et al.ISSTA 2020 · 44 citations
  4. FLEX: fixing flaky tests in machine learning projects by updating assertion boundsSaikat Dutta, August Shi, Sasa MisailovicFSE 2021 · 33 citations
  5. Domain-Specific Fixes for Flaky Tests with Wrong Assumptions on Underdetermined SpecificationsPeilun Zhang, Yanjie Jiang, Anjiang Wei, Victoria Stodden et al.ICSE 2021 · 26 citations

Related papers

  1. A Dataset of Reproducible Flaky-Test FailuresSuzzana Rafi, Mahbub-Ul-Hoque Sumon, Md Erfan, Maruf Morshed Khan et al.ISSTA 2026
  2. Systematically Producing Test Orders to Detect Order-Dependent Flaky TestsChengpeng Li, Mohammad Mahdi Khosravi, Wing Lam, August ShiISSTA 2023 · 10 citations
  3. FlakeSync: Automatically Repairing Async Flaky TestsShanto Rahman, August ShiICSE 2024 · 7 citations
  4. Neurosymbolic Repair of Test FlakinessYang Chen, Reyhaneh JabbarvandISSTA 2024 · 8 citations
  5. FlakiMe: Laboratory-Controlled Test Flakiness Impact AssessmentMaxime Cordy, Renaud Rwemalika, Adriano Franci, Mike Papadakis et al.ICSE 2022 · 14 citations
Dusk over the sea between two cliffs drawn in fine vertical lines