RATester enhances LLMs' ability to generate accurate unit tests by using the gopls language server to fetch precise contextual information when encountering unfamiliar code elements during test generation.
-----
https://arxiv.org/abs/2501.07425
Original Problem π:
LLMs often produce hallucinations when generating unit tests, like calling non-existent methods or using incorrect parameter types, due to limited awareness of project context.
-----
Solution in this Paper π οΈ:
β RATester integrates the gopls language server to provide LLMs with repository-wide knowledge.
β When encountering unfamiliar identifiers, RATester fetches their definitions and documentation using gopls.
β This contextual information is injected into the LLM's prompt template during test generation.
β The system continuously enriches the LLM's understanding of the project's global context.
-----
Key Insights from this Paper:
β Fixed context patterns used by existing approaches can miss important information or include irrelevant details
β Dynamic context fetching based on actual generation needs produces better results than static approaches
β Language server integration can effectively simulate human developers' IDE-assisted coding process
-----
Results π:
β Improved compile rate from 16.67%-63.56% to 45.58%-69.49%
β Increased line coverage by 16.30%-165.69% compared to baselines
β Successfully killed 25-147 more mutants in mutation testing










