Skip to main content
QUICK REVIEW

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

Alexander Berndt, Vekil Bekmyradov|arXiv (Cornell University)|Feb 5, 2026
Software Engineering ResearchComputer Science0 citations
TL;DR

The study evaluates whether large language models can classify flaky tests using only test code, finding that LLMs struggle with this task, showing weak MCC scores, notable non-determinism, and limited human feasibility without additional context.

ABSTRACT

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.

Motivation & Objective

  • Assess whether pre-trained LLMs can classify flaky tests using only test code without task-specific fine-tuning.
  • Evaluate multiple prompting strategies (zero-shot, zero-shot CoT, few-shot CoT) across benchmark datasets.
  • Analyze the determinism of LLM-based classifications and compare with human judgment on test-code-based flakiness.
  • Provide recommendations for future research on incorporating additional context or retrieval-augmented approaches.

Proposed method

  • Evaluate three LLMs (GPT-4o, GPT-OSS-120b, Qwen3-Coder-480b) under four prompt settings with temperature 0.
  • Use zero-shot, zero-shot chain-of-thought, and few-shot chain-of-thought prompts with six in-context demonstrations (three flaky, three non-flaky).
  • Test on two flakiness benchmarks (IDoFT subset and FlakeBench) and measure weighted precision, weighted recall, weighted F1, and MCC.
  • Assess non-determinism via normalized Hamming distance across three repetitions per setting.
  • Conduct a manual human judgment study on 50 flaky samples from IDoFT to evaluate feasibility of test-code-only classification.

Experimental results

Research questions

  • RQ1RQ1: How do LLMs perform in flaky-test classification based on test code under zero-shot, zero-shot CoT, and few-shot CoT prompts?
  • RQ2RQ2: What is the degree of non-determinism in LLM-based flaky-test classification across repeated runs?
  • RQ3RQ3: To what extent can humans classify flaky tests using only test code?

Key findings

  • LLMs show poor performance in classifying flaky tests using only test code across both datasets.
  • On IDoFT, the best MCC achieved with few-shot CoT is 0.27; on FlakeBench, MCC peaks at 0.17 with zero-shot prompting for GPT-OSS.
  • Few-shot prompting generally improves IDoFT results for general-purpose models, but overall performance remains weak (MCC ≤ 0.27).
  • Significant non-determinism is observed (normalized Hamming distance up to 0.25 on some settings), raising reliability concerns for production use.
  • Qwen-Code exhibits lower non-determinism overall and can yield identical results across repetitions in some settings.
  • Manual human analysis suggests test code alone is insufficient to identify more sophisticated flakiness types; some flakiness requires context beyond the test code.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.