Unit Test Generation using Generative AI : A Comparative Performance Analysis of Autogeneration Tools

要約

単体テストの生成はソフトウェア開発において重要なタスクであり、プログラマーには多大な時間と労力を要します。
大規模言語モデル (LLM) の出現により、単体テスト スクリプト生成のための新しい手段が導入されました。
この研究の目的は、Python プログラムの単体テスト スクリプトを生成するための LLM、特に ChatGPT に代表される LLM の有効性と、生成されたテスト ケースが既存の単体テスト ジェネレーター (Pynguin) によって生成されたテスト ケースとどのように比較されるかを実験的に調査することです。
実験では、1) 手続き型スクリプト、2) 関数ベースのモジュール コード、3) クラスベースのコードの 3 種類のコード ユニットを検討します。
生成されたテスト ケースは、カバレッジ、正確性、可読性などの基準に基づいて評価されます。
私たちの結果は、ChatGPT のパフォーマンスがカバレッジの点では Pynguin に匹敵しますが、場合によってはそのパフォーマンスが Pynguin よりも優れていることを示しています。
また、一部のカテゴリに対して ChatGPT によって生成されたアサーションの約 3 分の 1 が間違っていたこともわかりました。
また、私たちの結果は、ChatGPT と Pynguin の間で欠落したステートメントの重複が最小限であることを示しており、したがって、両方のツールを組み合わせることで単体テスト生成のパフォーマンスが向上する可能性があることを示唆しています。
最後に、私たちの実験では、迅速なエンジニアリングにより ChatGPT のパフォーマンスが向上し、より高いカバレッジが達成されました。

要約(オリジナル)

Generating unit tests is a crucial task in software development, demanding substantial time and effort from programmers. The advent of Large Language Models (LLMs) introduces a novel avenue for unit test script generation. This research aims to experimentally investigate the effectiveness of LLMs, specifically exemplified by ChatGPT, for generating unit test scripts for Python programs, and how the generated test cases compare with those generated by an existing unit test generator (Pynguin). For experiments, we consider three types of code units: 1) Procedural scripts, 2) Function-based modular code, and 3) Class-based code. The generated test cases are evaluated based on criteria such as coverage, correctness, and readability. Our results show that ChatGPT’s performance is comparable with Pynguin in terms of coverage, though for some cases its performance is superior to Pynguin. We also find that about a third of assertions generated by ChatGPT for some categories were incorrect. Our results also show that there is minimal overlap in missed statements between ChatGPT and Pynguin, thus, suggesting that a combination of both tools may enhance unit test generation performance. Finally, in our experiments, prompt engineering improved ChatGPT’s performance, achieving a much higher coverage.

arxiv情報

著者 Shreya Bhatia,Tarushi Gandhi,Dhruv Kumar,Pankaj Jalote
発行日 2024-02-13 15:18:29+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.AI, cs.SE パーマリンク