Skip to main content
QUICK REVIEW

[Paper Review] LLM-Powered Test Case Generation for Detecting Bugs in Plausible Programs

Kaibo Liu, Zhenpeng Chen|arXiv (Cornell University)|Apr 16, 2024
Electrostatic Discharge in ElectronicsEngineering3 citations
TL;DR

This paper proposes AID, a novel method that combines large language models (LLMs) with differential testing to generate high-precision test cases for detecting tricky bugs in plausibly correct programs. By using PUT-guided program generation, generator-based input generation, and diversity-first differential testing, AID achieves up to 2.65× higher precision and 1.80× higher recall than state-of-the-art methods on TrickyBugs and EvalPlus datasets.

ABSTRACT

Detecting tricky bugs in plausible programs, those that pass existing test suites yet still contain bugs, remains a significant challenge in software testing. To address this problem, we propose TrickCatcher, an LLM-powered approach to generating test cases for uncovering bugs in plausible programs. TrickCatcher operates in three stages: First, it uses an LLM to generate program variants based on the program under test (PUT) and its specification. Second, it employs an LLM to construct an input generator from the specification for producing test inputs. Finally, these inputs are executed on both the PUT and its program variants to detect inconsistencies in their outputs. We evaluate TrickCatcher on two datasets, TrickyBugs and EvalPlus, which include 366 human-written and 151 AI-generated plausible programs with tricky bugs. TrickCatcher achieves recall, precision, and F1 scores that are 1.80x, 2.65x, and 1.66x those of the state-of-the-art baselines, respectively. Code and data used are available at https://github.com/RinCloud/TrickCatcher.

Motivation & Objective

  • Address the critical challenge of generating accurate test oracles and inputs for detecting subtle, hard-to-find bugs in programs that pass all existing tests.
  • Overcome the low precision (as low as 6.3%) of direct LLM-based test generation due to incorrect oracles and illegal inputs.
  • Improve reliability and effectiveness of automated test generation in real-world scenarios where programs are already considered plausible but may harbor hidden defects.
  • Develop a practical, scalable method that integrates LLMs with differential testing to enhance test case quality and fault-detection capability.

Proposed method

  • Use LLMs to generate program variants guided by both the program under test (PUT) and its specification, improving variant correctness through PUT-aware prompting.
  • Replace direct LLM-based test input generation with code generator generation—LLMs produce executable scripts (e.g., Python) that enforce input constraints, ensuring legality and correctness.
  • Apply differential testing by feeding generated inputs to the PUT and its variants, flagging inconsistencies as potential bugs.
  • Prioritize input diversity during differential testing to maximize coverage of edge cases and increase the likelihood of revealing subtle faults.
  • Filter generated variants using existing test suites to eliminate incorrect or broken variants before differential testing.
  • Use a combinatorial sampling strategy to reduce randomness and improve reproducibility in evaluation.
Figure 1 . A motivating example.
Figure 1 . A motivating example.

Experimental results

Research questions

  • RQ1Can LLM-powered test generation achieve high precision in detecting tricky bugs in plausibly correct programs when direct prompting yields only 6.3% precision?
  • RQ2How effective is combining LLM-generated program variants with differential testing in uncovering subtle functional defects?
  • RQ3To what extent do PUT-guided program generation and generator-based input generation improve the reliability and correctness of test case generation?
  • RQ4Does prioritizing diversity in test input selection significantly enhance fault detection compared to random or non-diverse selection?
  • RQ5How does AID compare in performance to state-of-the-art methods like Differential Prompting and TOGA on real-world, complex coding benchmarks?

Key findings

  • AID achieves up to 1.80× higher recall and 2.65× higher precision than the best existing method (Differential Prompting) on the TrickyBugs and EvalPlus datasets.
  • The F1 score of AID exceeds the state-of-the-art by up to 1.66×, demonstrating superior overall performance in detecting tricky bugs.
  • The ablation study confirms that each component—PUT-guided generation, generator-based input generation, and diversity-first testing—contributes significantly to AID’s performance.
  • AID reduces the rate of illegal test inputs from 40.1% (in direct LLM generation) to near zero by generating constrained inputs via executable code generators.
  • The method achieves test oracle precision between 69.3% and 85.1%, making it practical for real-world deployment, unlike prior methods with sub-1% precision.
  • The replication package is publicly released, ensuring reproducibility and supporting future extension to broader application scenarios.
Figure 2 . Overview of AID .
Figure 2 . Overview of AID .

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.