mlsanityData to 7 Oct 2026

LLM-based Unit Test Generation via Property Retrieval

arXiv 2410.13542 ↗First posted 17 Oct 2024cs.SEcited by 6

Not on the map. Why?

Abstract (arXiv)

Automated unit test generation has been widely studied, with Large Language Models (LLMs) recently showing significant potential. Moreover, in the context of unit test generation, these tools prioritize high code coverage, often at the expense of practical usability, correctness, and maintainability. In response, we propose Property-Based Retrieval Augmentation, a novel mechanism that extends LLM-based Retrieval-Augmented Generation (RAG) beyond basic vector, text similarity, and graph-based methods. Our approach considers task-specific context and introduces a tailored property retrieval mechanism. Specifically, in the unit test generation task, we account for the unique structure of unit tests by dividing the test generation process into Given, When, and Then phases. When generating tests for a focal method, we not only retrieve general context for the code under test but also consider task-specific context such as pre-existing tests of other methods, which can provide valuable insights for any of the Given, When, and Then phases. This forms property relationships between focal method and other methods, thereby expanding the scope of retrieval beyond traditional RAG. We implement this approach in a tool called APT, which sequentially performs preprocessing, property retrieval, and unit test generation, using an iterative strategy where newly generated tests guide the creation of subsequent ones. We evaluated APT on 12 open-source projects with 1515 methods, and the results demonstrate that APT consistently outperforms existing tools in terms of correctness, completeness, and maintainability of the generated tests. Moreover, we introduce a novel code-context-aware retrieval mechanism for LLMs beyond general context, offering valuable insights and potential applications for other code-related tasks.

Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). First posted on arXiv 17 Oct 2024.

Builds on

No reference list yet.

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 5; 2026: 1.

6 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026Enhancing Large Language Models with Retrieval Augmented Generation for Software Testing and Inspection Automation
  2. 2024Retrieval-Augmented Test Generation: How Far Are We?
  3. 2025Improving Retrieval-Augmented Deep Assertion Generation via Joint Training
  4. 2025LSPRAG: LSP-Guided RAG for Language-Agnostic Real-Time Unit Test Generation
  5. 2025AugmenTest: Enhancing Tests with LLM-Driven Oracles
  6. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
  7. 2026Not All RAGs Are Created Equal: A Component-Wise Empirical Study for Software Engineering Tasks
  8. 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval