An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generation
Max Schäfer
Sarah NadiAryaz EghbaliFTFrank Tip Max Schäfer

Sarah Nadi
Aryaz Eghbali
FTFrank Tip
+4
This paper presents a large-scale evaluation of using large language models (LLMs) for automated unit test generation without additional training or manual effort. The approach, implemented in TestPilot for JavaScript, provides the LLM with the function signature, implementation, and usage examples from documentation. TestPilot uses OpenAI's gpt3.5-turbo to generate tests for 1,684 API functions across 25 npm packages, achieving median statement coverage of 70.2% and branch coverage of 52.8%, significantly outperforming the baseline technique Nessie. The generated tests are mostly novel, with 92.8% having less than 50% similarity to existing tests. The effectiveness is consistent across different LLMs, though influenced by model size and training data.

arXiv ·
· February 13, 2023