Measuring the Influence of Incorrect Code on Test Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Huang, Dong, Zhang, Jie M., Harman, Mark, Du, Mingzhe, Cui, Heming
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916664325439488
author Huang, Dong
Zhang, Jie M.
Harman, Mark
Du, Mingzhe
Cui, Heming
author_facet Huang, Dong
Zhang, Jie M.
Harman, Mark
Du, Mingzhe
Cui, Heming
contents It is natural to suppose that a Large Language Model is more likely to generate correct test cases when prompted with correct code under test, compared to incorrect code under test. However, the size of this effect has never been previously measured, despite its obvious importance for both practicing software engineers and researchers. To answer the question, we conducted a comprehensive empirical study on 5 open source and 6 closed source language models, with 3 widely-used benchmark data sets together with 41 repo-level real-world examples from two different real-world data sets. Our results reveal that, when compared to incorrect code under test, LLMs prompted with correct code achieve improvements in test accuracy, code coverage, and bug detection of 57\%, 12\%, and 24\% respectively. We further show that these scientific conclusions carry over from the three benchmark data sets to the real-world code, where tests generated for incorrect code experience a 47\% worse bug detection rate. Finally, we report that improvements of +18\% in accuracy, +4\% coverage, and +34\% in bug detection can be achieved by providing natural language code descriptions. These findings have actionable conclusions. For example, the 47\% reduction in real-world bug detection is a clear concern. Fortunately, it is a concern for which our findings about the added value of descriptions offer an immediately actionable remedy.
format Preprint
id arxiv_https___arxiv_org_abs_2409_09464
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Measuring the Influence of Incorrect Code on Test Generation
Huang, Dong
Zhang, Jie M.
Harman, Mark
Du, Mingzhe
Cui, Heming
Software Engineering
Computation and Language
It is natural to suppose that a Large Language Model is more likely to generate correct test cases when prompted with correct code under test, compared to incorrect code under test. However, the size of this effect has never been previously measured, despite its obvious importance for both practicing software engineers and researchers. To answer the question, we conducted a comprehensive empirical study on 5 open source and 6 closed source language models, with 3 widely-used benchmark data sets together with 41 repo-level real-world examples from two different real-world data sets. Our results reveal that, when compared to incorrect code under test, LLMs prompted with correct code achieve improvements in test accuracy, code coverage, and bug detection of 57\%, 12\%, and 24\% respectively. We further show that these scientific conclusions carry over from the three benchmark data sets to the real-world code, where tests generated for incorrect code experience a 47\% worse bug detection rate. Finally, we report that improvements of +18\% in accuracy, +4\% coverage, and +34\% in bug detection can be achieved by providing natural language code descriptions. These findings have actionable conclusions. For example, the 47\% reduction in real-world bug detection is a clear concern. Fortunately, it is a concern for which our findings about the added value of descriptions offer an immediately actionable remedy.
title Measuring the Influence of Incorrect Code on Test Generation
topic Software Engineering
Computation and Language
url https://arxiv.org/abs/2409.09464