A Preliminary Study of Test Flakiness in Large Language Model Generated Tests

Authors

  • Hana Kopuncova Department of Computer Science, George Mason University, Fairfax, VA
  • Devanshi Kashyap Department of Computer Science, George Mason University, Fairfax, VA
  • Suzzana Rafi Department of Computer Science, George Mason University, Fairfax, VA
  • Shanto Rahman Department of Electrical and Computer Engineering, University of Texas, Austin, TX
  • August Shi Department of Electrical and Computer Engineering, University of Texas, Austin, TX
  • Wing Lam Department of Computer Science, George Mason University, Fairfax, VA

DOI:

https://doi.org/10.13021/jssr2026.5662

Abstract

Developers trust automated tests to catch bugs before they reach users, yet a growing class of tests undermines that trust entirely: flaky tests, which pass and fail unpredictably on the same version of code. The rise of test generation using large language models (LLMs) raises a critical question the field has not yet answered — do these tools generate tests that are flaky? To find out, we run popular large language model based test generation tools on four open-source Java projects. Across 182 generated tests with a 93% pass rate, one confirmed flaky test was found. This flaky test used a HashMap and assumed a fixed data ordering that Java does not guarantee. To better understand the flakiness of LLM-generated tests, future work should evaluate test generation on focal methods that are known to have resulted in flaky tests. This line of future work can shed more light into the flakiness of LLM-generated tests and provide insights into what characteristics commonly occur in focal methods that result in flaky tests. Our preliminary findings show that LLM-generated tests carry a distinct flakiness risk rooted in the model's incorrect assumptions about Java runtime behavior, which is a risk that grows more consequential as LLM testing tools see wider adoption.

Published

2026-09-24

Issue

Section

College of Engineering and Computing: Department of Computer Science