An Empirical Study of Using Large Language Models for Unit Test Generation
Siddiq, Mohammed Latif, Santos, Joanna C. S., Tanvir, Ridwanul Hasan, Ulfat, Noshin, Rifat, Fahmid Al, Lopes, Vinicius Carvalho
–arXiv.org Artificial Intelligence
A code generation model generates code by taking a prompt from a code comment, existing code, or a combination of both. Although code generation models (e.g., GitHub Copilot) are increasingly being adopted in practice, it is unclear whether they can successfully be used for unit test generation without fine-tuning for a strongly typed language like Java. To fill this gap, we investigated how well three models (Codex, GPT-3.5-Turbo, and StarCoder) can generate unit tests. We used two benchmarks (HumanEval and Evosuite SF110) to investigate the effect of context generation on the unit test generation process. We evaluated the models based on compilation rates, test correctness, test coverage, and test smells. We found that the Codex model achieved above 80% coverage for the HumanEval dataset, but no model had more than 2% coverage for the EvoSuite SF110 benchmark. The generated tests also suffered from test smells, such as Duplicated Asserts and Empty Tests.
arXiv.org Artificial Intelligence
Jan-22-2024
- Country:
- North America
- Dominican Republic (0.04)
- United States
- District of Columbia > Washington (0.05)
- Pennsylvania > Centre County
- University Park (0.04)
- New York > New York County
- New York City (0.05)
- Indiana > St. Joseph County
- Notre Dame (0.04)
- California
- San Francisco County > San Francisco (0.14)
- San Diego County > San Diego (0.04)
- Canada
- Ontario > Toronto (0.04)
- British Columbia > Metro Vancouver Regional District
- Vancouver (0.04)
- Europe
- Switzerland > Zürich
- Zürich (0.04)
- Hungary > Csongrád-Csanád County
- Szeged (0.04)
- France > Occitanie
- Hérault > Montpellier (0.04)
- Finland > Southwest Finland
- Turku (0.04)
- Estonia > Harju County
- Tallinn (0.04)
- Switzerland > Zürich
- Asia > Bangladesh
- Dhaka Division > Dhaka District > Dhaka (0.04)
- North America
- Genre:
- Research Report > New Finding (0.67)
- Industry:
- Information Technology (0.93)
- Technology: