From Prompts to Properties: Rethinking LLM Code Generation with Property-Based Testing
Large Language Models (LLMs) have shown promise in automated code generation, but ensuring correctness remains a significant challenge. Traditional unit testing evaluates functional correctness but often fails to capture deeper logical constraints. We apply Property-Based Testing (PBT) as an alternative evaluation strategy to StarCoder and CodeLlama on MBPP and HumanEval. Our results reveal that while pass@k evaluation shows moderate success, PBT exposes additional correctness gaps. A significant portion of generated solutions only partially adhere to correctness properties (30–32%), while 18–23% fail outright. Property extraction is also imperfect, with 9–13% of constraints missing. These findings highlight that unit test-based evaluations may overestimate solution correctness by not capturing fundamental logical errors. Our study demonstrates that combining unit testing with PBT can offer a more comprehensive assessment of generated code correctness, revealing limitations that traditional verification approaches miss.
Authors
- Dibyendu Brinto Bose (ORCID: https://orcid.org/0000-0002-1603-3574)
Institutions
- Virginia Tech (US)
Publication Details
- Published
- 2025-06-23
- DOI
- https://doi.org/10.1145/3696630.3728702
- Citations
- 2
- Primary Topic
- Digital Rights Management and Security
- Type
- article
- Field-Weighted Citation Impact
- 6.49