On the Flakiness of LLM-Generated Tests for Industrial and Open-Source Database Management Systems
Alexander Berndt, Thomas Bach, Rainer Gemulla, Marcus Kessel, Sebastian Baltes
TL;DR
The paper investigates the flakiness of LLM-generated tests in both industrial and open-source DBMS contexts, revealing that generated tests can be slightly more flaky than existing ones. Using a meta-generation approach with two LLMs, the study analyzes native C++ and SQL tests across SAP HANA, DuckDB, MySQL, and SQLite, showing unordered-collection–driven flakiness as the primary cause and demonstrating transfer of existing flaky behavior via prompt context. It also shows that closed-source systems like SAP HANA are more susceptible to flakiness transfer and that merely providing more context to LLMs is not a sufficient safeguard. The findings highlight the need for tailored, system-specific context and robust validation when employing LLMs for test generation, to mitigate non-functional flaws and maintain CI reliability.
Abstract
Flaky tests are a common problem in software testing. They produce inconsistent results when executed multiple times on the same code, invalidating the assumption that a test failure indicates a software defect. Recent work on LLM-based test generation has identified flakiness as a potential problem with generated tests. However, its prevalence and underlying causes are unclear. We examined the flakiness of LLM-generated tests in the context of four relational database management systems: SAP HANA, DuckDB, MySQL, and SQLite. We amplified test suites with two LLMs, GPT-4o and Mistral-Large-Instruct-2407, to assess the flakiness of the generated test cases. Our results suggest that generated tests have a slightly higher proportion of flaky tests compared to existing tests. Based on a manual inspection, we found that the most common root cause of flakiness was the reliance of a test on a certain order that is not guaranteed ("unordered collection"), which was present in 72 of 115 flaky tests (63%). Furthermore, both LLMs transferred the flakiness from the existing tests to the newly generated tests via the provided prompt context. Our experiments suggest that flakiness transfer is more prevalent in closed-source systems such as SAP HANA than in open-source systems. Our study informs developers on what types of flakiness to expect from LLM-generated tests. It also highlights the importance of providing LLMs with tailored context when employing LLMs for test generation.
