arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2310.00483cs.SEcs.LG
收藏

提示代码解释器为Quixbugs函数编写更优单元测试

Prompting Code Interpreter to Write Better Unit Tests on Quixbugs Functions

University of Chicago(芝加哥大学);Yale University(耶鲁大学);Hewlett Packard Enterprise(慧与公司)

Vincent Li, Nick Doiron

AI总结:

本研究探究不同提示对Code Interpreter针对Quixbugs数据集Python函数生成单元测试质量的影响,发现提示细节对测试质量影响小,但提供可运行代码辅助纠错有益,为同类模型的提示设计提供参考。

摘要:

单元测试是软件工程中用于测试所编写代码的正确性与鲁棒性的常用方法。单元测试是被设计用于隔离测试代码库小型组件(如单个函数或方法)的测试。尽管单元测试历来由人类程序员编写,但人工智能尤其是大语言模型(LLM)的最新进展,也推动了自动单元测试生成的相应发展。在本研究中,我们探究不同提示对基于GPT-4的大语言模型Code Interpreter(代码解释器)针对Quixbugs数据集提供的Python函数生成的单元测试质量的影响,我们聚焦提示策略是因为用户能够轻松应用我们的发现与观察结果。我们发现,生成的单元测试质量对所提供提示的细微细节变化不敏感。然而,我们观察到Code Interpreter通常能够有效识别并纠正它所编写代码中的错误,这表明为其提供可运行代码以检查输出正确性是有益的,尽管我们发现它通常已经能够生成格式正确的单元测试。我们的发现表明,在为类似Code Interpreter的模型设计提示时,包含生成单元测试所需的基本信息很重要,但细微细节的重要性较低。

英文摘要:

Unit testing is a commonly-used approach in software engineering to test the correctness and robustness of written code. Unit tests are tests designed to test small components of a codebase in isolation, such as an individual function or method. Although unit tests have historically been written by human programmers, recent advancements in AI, particularly LLMs, have shown corresponding advances in automatic unit test generation. In this study, we explore the effect of different prompts on the quality of unit tests generated by Code Interpreter, a GPT-4-based LLM, on Python functions provided by the Quixbugs dataset, and we focus on prompting due to the ease with which users can make use of our findings and observations. We find that the quality of the generated unit tests is not sensitive to changes in minor details in the prompts provided. However, we observe that Code Interpreter is often able to effectively identify and correct mistakes in code that it writes, suggesting that providing it runnable code to check the correctness of its outputs would be beneficial, even though we find that it is already often able to generate correctly-formatted unit tests. Our findings suggest that, when prompting models similar to Code Interpreter, it is important to include the basic information necessary to generate unit tests, but minor details are not as important.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑