# IGTG&R: An Intent Analysis-Guided Unit Test Generation and Refinement Framework

**Authors:** Xiaojian Liu, Yangyang Zhang

PMC · DOI: 10.3390/e28010074 · Entropy · 2026-01-09

## TL;DR

This paper introduces a new framework for generating unit tests that combines code coverage and intent analysis to better detect functional defects in code.

## Contribution

The novel IGTG&R framework combines coverage path entropy and LLM-based refinement to improve functional defect detection in unit tests.

## Key findings

- IGTG&R achieves 100% execution success rate and 75.8% code coverage.
- The framework identifies functional defects with a rate of 65% to 89%.
- Excluding focal method bodies reduces interference in intent analysis.

## Abstract

Code coverage-guided unit test generation (CGTG) and large language model-based test generation (LLMTG) are two principal approaches for the generation of unit tests. Each of these approaches has its inherent advantages and drawbacks. Tests generated by CGTG have been shown to exhibit high code coverage and high executability. However, they lack the capacity to comprehend code intent, which results in an inability to identify deviations between code implementation and design intent (i.e., functional defects). Conversely, although LLMTG demonstrates an advantage in terms of code intent analysis, it is generally characterized by low executability and necessitates iterative debugging. In order to enhance the ability of unit test generation to identify functional defects, a novel framework has been proposed, entitled the intent analysis-guided unit test generation and refinement (IGTG&R) model. The IGTG&R model consists of a two-stage process for test generation. In the first stage, we introduce coverage path entropy to enhance CGTG to achieve high executability and code coverage of test cases. The second stage refines the test cases using LLMs to identify functional defects. We quantify and verify the interference of incorrect code implementation on intent analysis through conditional entropy. In order to reduce this interference, the focal method body is excluded from the code context information during intent analysis. Using these two-stage process, IGTG&R achieves a more profound comprehension of the intent of the code and the identification of functional defects. The IGTG&R model has been demonstrated to achieve an identification rate of functional defects ranging from 65% to 89%, with an execution success rate of 100% and a code coverage rate of 75.8%. This indicates that IGTG&R is superior to the CGTG and LLMTG approaches in multiple aspects.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/PMC12839985/full.md

## Figures

7 figures with captions in the complete paper: https://tomesphere.com/paper/PMC12839985/full.md

## References

22 references — full list in the complete paper: https://tomesphere.com/paper/PMC12839985/full.md

---
Source: https://tomesphere.com/paper/PMC12839985