Skip to main content
QUICK REVIEW

[Paper Review] TOGLL: Correct and Strong Test Oracle Generation with LLMs

Soneya Binta Hossain, Matthew B. Dwyer|arXiv (Cornell University)|May 6, 2024
Scientific Computing and Data ManagementDecision Sciences7 citations
TL;DR

This paper studies fine-tuned code LLMs to generate correct, strong, and diverse test oracles, introducing TOGLL and showing substantial gains over TOGA and EvoSuite in accuracy, diversity, and bug detection on unseen Java projects.

ABSTRACT

Test oracles play a crucial role in software testing, enabling effective bug detection. Despite initial promise, neural-based methods for automated test oracle generation often result in a large number of false positives and weaker test oracles. While LLMs have demonstrated impressive effectiveness in various software engineering tasks, including code generation, test case creation, and bug fixing, there remains a notable absence of large-scale studies exploring their effectiveness in test oracle generation. The question of whether LLMs can address the challenges in effective oracle generation is both compelling and requires thorough investigation. In this research, we present the first comprehensive study to investigate the capabilities of LLMs in generating correct, diverse, and strong test oracles capable of effectively identifying a large number of unique bugs. To this end, we fine-tuned seven code LLMs using six distinct prompts on the SF110 dataset. Utilizing the most effective fine-tuned LLM and prompt pair, we introduce TOGLL, a novel LLM-based method for test oracle generation. To investigate the generalizability of TOGLL, we conduct studies on 25 large-scale Java projects. Besides assessing the correctness, we also assess the diversity and strength of the generated oracles. We compare the results against EvoSuite and the state-of-the-art neural method, TOGA. Our findings reveal that TOGLL can produce 3.8 times more correct assertion oracles and 4.9 times more exception oracles. Moreover, our findings demonstrate that TOGLL is capable of generating significantly diverse test oracles. It can detect 1,023 unique bugs that EvoSuite cannot, which is ten times more than what the previous SOTA neural-based method, TOGA, can detect.

Motivation & Objective

  • Investigate whether fine-tuned code LLMs can generate correct and strong test oracles for software testing.
  • Assess the generalizability of LLM-generated oracles to unseen large-scale Java projects.
  • Evaluate the diversity and bug-detection strength of LLM-generated oracles against state-of-the-art baselines.
  • Provide datasets, models, and code to enable replication and further research in LLM-based test oracle generation.

Proposed method

  • Fine-tune seven code LLMs (110M–2.7B params) on a SF110-derived dataset of test prefixes, MUTs, and docstrings with six prompts varying context.
  • Select the best model-prompt pair based on accuracy on a validation set to define TOGLL.
  • Evaluate correctness by executing test suites that integrate generated oracles, measuring success rate (non-empty, correct oracles that pass).
  • Compare TOGLL against TOGA (state-of-the-art neural method) and EvoSuite across 25 unseen large Java projects.
  • Assess oracle strength via mutation testing using PIT to measure mutant detection and unique mutants killed.
  • Analyze diversity of generated assertions and their distribution across common assertion categories.
Figure 1: Overview of our approach to explore LLM-based oracle generation and to evaluate TOGLL.
Figure 1: Overview of our approach to explore LLM-based oracle generation and to evaluate TOGLL.

Experimental results

Research questions

  • RQ1RQ1: Which LLM and prompting approach yields the most effective test oracles for generation accuracy?
  • RQ2RQ2: How well does the TOGLL fine-tuned model generate correct test oracles on unseen projects compared to baselines?
  • RQ3RQ3: How diverse are LLM-generated assertions relative to EvoSuite-generated ones?
  • RQ4RQ4: How strong are the generated assertions at identifying unique bugs via mutation testing?

Key findings

  • TOGLL achieves higher correct oracle generation than TOGA, with up to 3.8x improvement for assertion oracles and 4.9x for exception oracles on unseen projects.
  • TOGLL generates significantly more diverse assertions than EvoSuite, with many unique observation targets and only 18,630 exact matches out of 194,871 generated assertions.
  • On unseen projects, TOGLL detects 1,023 unique mutants (10x more than TOGA and substantially more than EvoSuite), indicating strong bug-detection capabilities.
  • Prompt context matters: adding method signatures or full method code improves accuracy, with P5 (entire MUT) and P6 (doc+MUT) often performing best across models; docstrings alone yield smaller gains.
  • Among evaluated models, CodeGen-350M and CodeParrot-110M were the top performers overall for the most effective prompts (P4–P6).
  • TOGLL maintains strong performance across 25 real-world projects, with a mean correct oracle success rate of 63% for assertions and 93.4% for exceptions, outperforming TOGA significantly.
Figure 2: EvoSuite-Generated Test Cases with Assertion and Exception Oracles. The prefix part is marked with yellow color.
Figure 2: EvoSuite-Generated Test Cases with Assertion and Exception Oracles. The prefix part is marked with yellow color.

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.