A Systematic Approach for Assessing Large Language Models' Test Case Generation Capability
Hung-Fu Chang, Mohammad Shokrolah Shirazi
TL;DR
This work tackles the lack of standardized benchmarks for evaluating large language models (LLMs) in automated unit-test generation. It introduces GBCV, Generated Benchmark from Control-Flow Structure and Variable Usage Composition, a CFG/data-flow-guided method to generate scalable program benchmarks that span simple to complex control-flow structures. The study evaluates GPT-3-Turbo, GPT-4o-mini, and GPT-4o on these benchmarks, finding GPT-4o excels with complex program structures while boundary-value detection remains reliable in simple conditions; arithmetic computations, however, remain a persistent challenge. The results establish key strengths and limitations of current LLMs in test generation and provide a flexible framework for expanding benchmarks and guiding future model improvements.
Abstract
Software testing ensures the quality and reliability of software products, but manual test case creation is labor-intensive. With the rise of large language models (LLMs), there is growing interest in unit test creation with LLMs. However, effective assessment of LLM-generated test cases is limited by the lack of standardized benchmarks that comprehensively cover diverse programming scenarios. To address the assessment of LLM's test case generation ability and lacking dataset for evaluation, we propose the Generated Benchmark from Control-Flow Structure and Variable Usage Composition (GBCV) approach, which systematically generates programs used for evaluating LLMs' test generation capabilities. By leveraging basic control-flow structures and variable usage, GBCV provides a flexible framework to create a spectrum of programs ranging from simple to complex. Because GPT-4o and GPT-3-Turbo are publicly accessible models, to present real-world regular user's use case, we use GBCV to assess LLM performance on them. Our findings indicate that GPT-4o performs better on complex program structures, while all models effectively detect boundary values in simple conditions but face challenges with arithmetic computations. This study highlights the strengths and limitations of LLMs in test generation, provides a benchmark framework, and suggests directions for future improvement.
