Grunnleggende konsepter
This paper introduces APT, a novel tool leveraging Large Language Models (LLMs) and a novel property-based retrieval augmentation approach to generate high-quality, maintainable unit tests by analyzing existing test cases and code relationships within a repository.
Sammendrag
APT: LLM-based Unit Test Generation via Property Retrieval for Enhanced Code Coverage and Test Quality
This research paper introduces APT (Property-Based Retrieval Augmentation for Unit Test Generation), a novel tool designed to improve the automated generation of unit tests. The authors argue that existing LLM-based unit test generation tools often prioritize code coverage over other crucial aspects like correctness, maintainability, and understandability.
This paper aims to address the limitations of existing LLM-based unit test generation tools by proposing a novel approach that leverages property relationships between methods within a code repository to generate more effective and higher-quality unit tests.
The researchers developed APT, which utilizes a multi-step process:
Metainfo Extraction: APT parses the source code into an Abstract Syntax Tree (AST) and transforms it into a relational structure stored in a Metainfo Database for efficient retrieval.
Test Case Analysis: Existing test cases are analyzed and abstracted into "Test Bundles," encapsulating the test case, fixtures, imports, and relevant class members.
Property Retrieval: APT identifies property relationships between methods based on similarities in their Given, When, and Then phases of unit tests. This analysis occurs both within a class (intra-class) and across classes (inter-class).
Unit Test Generation: APT leverages the identified property relationships and existing test bundles to generate new unit tests for focal methods. An iterative strategy is employed where newly generated tests guide the creation of subsequent ones.