Can We Classify Flaky Tests Using Only Test Code? An LLM-Based Empirical Study

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Berndt, Alexander, Bekmyradov, Vekil, Gemulla, Rainer, Kessel, Marcus, Bach, Thomas, Baltes, Sebastian
Format: Preprint
Publié: 2026
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866914307680239616
author Berndt, Alexander
Bekmyradov, Vekil
Gemulla, Rainer
Kessel, Marcus
Bach, Thomas
Baltes, Sebastian
author_facet Berndt, Alexander
Bekmyradov, Vekil
Gemulla, Rainer
Kessel, Marcus
Bach, Thomas
Baltes, Sebastian
contents Flaky tests yield inconsistent results when they are repeatedly executed on the same code revision. They interfere with automated quality assurance of code changes and hinder efficient software testing. Previous work evaluated approaches to train machine learning models to classify flaky tests based on identifiers in the test code. However, the resulting classifiers have been shown to lack generalizability, hindering their applicability in practical environments. Recently, pre-trained Large Language Models (LLMs) have shown the capability to generalize across various tasks. Thus, they represent a promising approach to address the generalizability problem of previous approaches. In this study, we evaluated three LLMs (two general-purpose models, one code-specific model) using three prompting techniques on two benchmark datasets from prior studies on flaky test classification. Furthermore, we manually investigated 50 samples from the given datasets to determine whether classifying flaky tests based only on test code is feasible for humans. Our findings indicate that LLMs struggle to classify flaky tests given only the test code. The results of our best prompt-model combination were only marginally better than random guessing. In our manual analysis, we found that the test code does not necessarily contain sufficient information for a flakiness classification. Our findings motivate future work to evaluate LLMs for flakiness classification with additional context, for example, using retrieval-augmented generation or agentic AI.
format Preprint
id arxiv_https___arxiv_org_abs_2602_05465
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Can We Classify Flaky Tests Using Only Test Code? An LLM-Based Empirical Study
Berndt, Alexander
Bekmyradov, Vekil
Gemulla, Rainer
Kessel, Marcus
Bach, Thomas
Baltes, Sebastian
Software Engineering
Flaky tests yield inconsistent results when they are repeatedly executed on the same code revision. They interfere with automated quality assurance of code changes and hinder efficient software testing. Previous work evaluated approaches to train machine learning models to classify flaky tests based on identifiers in the test code. However, the resulting classifiers have been shown to lack generalizability, hindering their applicability in practical environments. Recently, pre-trained Large Language Models (LLMs) have shown the capability to generalize across various tasks. Thus, they represent a promising approach to address the generalizability problem of previous approaches. In this study, we evaluated three LLMs (two general-purpose models, one code-specific model) using three prompting techniques on two benchmark datasets from prior studies on flaky test classification. Furthermore, we manually investigated 50 samples from the given datasets to determine whether classifying flaky tests based only on test code is feasible for humans. Our findings indicate that LLMs struggle to classify flaky tests given only the test code. The results of our best prompt-model combination were only marginally better than random guessing. In our manual analysis, we found that the test code does not necessarily contain sufficient information for a flakiness classification. Our findings motivate future work to evaluate LLMs for flakiness classification with additional context, for example, using retrieval-augmented generation or agentic AI.
title Can We Classify Flaky Tests Using Only Test Code? An LLM-Based Empirical Study
topic Software Engineering
url https://arxiv.org/abs/2602.05465