Causal testing: understanding defects' root causes

Brittany Johnson, Yuriy Brun, Alexandra Meliou

Abstract

Debugging remains one of the most time-consuming tasks in software development. While fault localization tools identify where a bug might be, they often fail to explain why it occurs. This paper presents Causal Testing, a framework that leverages counterfactual causality to identify root causes. By generating minimally different pairs of passing and failing tests, the approach highlights the specific inputs and execution paths responsible for a defect. Evaluation using the Defects4J benchmark and a human study demonstrates that Causal Testing improves root-cause identification accuracy from 80% to 86%.

Introduction

Modern debugging tools primarily focus on fault localization—pinpointing the specific lines of code associated with a failure. However, knowing the location of a bug is not synonymous with understanding its underlying cause. Developers often spend significant effort manually "fuzzing" inputs and tracing execution paths to find the boundary between success and failure. Causal Testing aims to automate this cognitive process by providing "near-miss" counterfactuals: inputs that are nearly identical to the failing case but result in a successful execution.

Methodology

The Causal Testing framework adopts a manipulationist approach to causal inference. Instead of passive observation, it actively experiments with the software to observe behavioral changes. The process consists of three primary stages:

  1. Input Perturbation: Starting with an initial failing test, the system employs fuzzing tools and automated test generators (e.g., EvoSuite) to create a diverse pool of similar test cases.
  2. Identifying Counterfactuals: The system identifies "minimally different" pairs consisting of one passing and one failing test. Similarity is determined through syntactic metrics (like Levenshtein distance) and execution path analysis (comparing method call sequences).
  3. Result Aggregation: The differences in inputs and execution traces are highlighted for the developer.
The Causal Testing workflow: from a failing test to aggregated causal results.

The authors implemented this framework in a prototype called Holmes, an Eclipse plugin that presents these pairs side-by-side, emphasizing the divergent execution paths.

Evaluation and Key Results

The effectiveness of Causal Testing was evaluated using Defects4J, a benchmark containing 330 real-world bugs from prominent Java projects. The study focused on the tool's applicability to these production-level defects and its impact on developer performance.

The evaluation revealed that Causal Testing is applicable to 71% of the real-world defects in the benchmark, providing helpful root-cause information in 77% of those cases. A controlled experiment involving 37 developers compared the use of Holmes against standard JUnit tools.

Comparison of root-cause identification accuracy between the control group and Holmes users across six defects.

As shown in the results, participants using Holmes achieved a higher accuracy rate in identifying root causes (86% vs. 80%). Interestingly, Holmes users occasionally took longer to resolve defects. This "understanding tax" suggests that causal information encourages developers to engage in deeper reflection rather than applying superficial "quick-fix" patches. Qualitative feedback confirmed this, with 46% of participants finding Holmes' output significantly more useful than standard failure traces.

Conclusion

Causal Testing represents a shift from simple fault localization to comprehensive root-cause analysis. By automating the search for counterfactual executions, it provides developers with the context needed to understand complex logic errors. Future work will focus on scaling the tool to handle complex object inputs and improving the summarization of long execution traces.

Summary updated

BibTeX
@inproceedings{johnson2020causal,
  author = {Brittany Johnson and Yuriy Brun and Alexandra Meliou},
  title = {{Causal testing: understanding defects' root causes}},
  booktitle = {ICSE},
  year = {2020},
  doi = {10.1145/3377811.3380377},
}
Figure