An Empirical Study on Pragmatic Unit Test Generation with Large Language Models | Research Square window.SnipcartSettings = { analytics: { enabled: false } }; (function() { var accessVector = localStorage.getItem('access_vector') || ''; window.dataLayer = window.dataLayer || []; if (accessVector) { window.dataLayer.push({ user: { profile: { profileInfo: { snid: accessVector } } } }); } })(); (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-K279D39R'); Browse Preprints In Review Journals COVID-19 Preprints AJE Video Bytes Research Tools Research Promotion AJE Professional Editing AJE Rubriq About Preprint Platform In Review Editorial Policies Our Team Advisory Board Help Center Sign In Submit a Preprint Cite Share Download PDF Research Article An Empirical Study on Pragmatic Unit Test Generation with Large Language Models Tian Lan, Kaiyuan Xue, Ruyuan Duan, Meng Sun This is a preprint; it has not been peer reviewed by a journal. https://doi.org/ 10.21203/rs.3.rs-9194820/v1 This work is licensed under a CC BY 4.0 License Status: Under Review Version 1 posted 4 You are reading this latest preprint version Abstract Unit testing validates whether a program unit (e.g., a function or a class) under test behaves correctly. To alleviate manual efforts in writing unit test cases, researchers have proposed various techniques to facilitate automated unit test generation, including the use of deep learning techniques (such as large language models in short as LLMs). To fully assess the effectiveness of unit test cases generated based on LLMs, in this paper, we propose the extensible TesterEval benchmark, which comprehensively assesses the unit test cases' quality in terms of compilability, code coverage, bug-finding ability, and false-positive bug warnings. To produce a representative and diverse benchmark for tasks of unit test generation, we construct TesterEval based on CoderEval, a state-of-the-art benchmark that evaluates code generation models for realistic scenarios of code generation. We evaluate and compare five state-of-the-art models (WizardCoder, DeepSeekCoder, Codellama, ChatGPT, and GPT4) on TesterEval. Experimental results reveal four important findings: (1) ChatGPT outperforms GPT4 in terms of compilability, code coverage, bug findings, and false-positive bug warnings, (2) all models perform worse on a non-standalone function (i.e., a function that invokes or accesses at least one non-built-in/non-standard-library function defined outside this function) than on a standalone function, (3) it is important yet challenging for all models to generate unit tests when given no test context (e.g., the unit tests' belonging test class), and (4) all models perform similarly between (a) when given only natural language description and the name and signature of the focal function (i.e., the function under test) and (b) when given only the focal function's implementation, implying that LLMs may help alleviate the manual efforts for developers during test-driven development. Code Coverage Unit Test Generation Large Language Models Benchmark Full Text Additional Declarations No competing interests reported. Cite Share Download PDF Status: Under Review Version 1 posted Reviewers invited by journal 05 Apr, 2026 Editor assigned by journal 28 Mar, 2026 Submission checks completed at journal 25 Mar, 2026 First submitted to journal 22 Mar, 2026 You are reading this latest preprint version Research Square lets you share your work early, gain feedback from the community, and start making changes to your manuscript prior to peer review in a journal. As a division of Research Square Company, we’re committed to making research communication faster, fairer, and more useful. We do this by developing innovative software and high quality services for the global research community. Our growing team is made up of researchers and industry professionals working together to solve the most critical problems facing scientific publishing. Also discoverable on Platform About Our Team In Review Editorial Policies Advisory Board Help Center Resources Author Services Accessibility API Access RSS feed Manage Cookie Preferences © Research Square 2026 | ISSN 2693-5015 (online) Privacy Policy Terms of Service Do Not Sell My Personal Information {"props":{"pageProps":{"initialData":{"identity":"rs-9194820","acceptedTermsAndConditions":true,"allowDirectSubmit":false,"archivedVersions":[],"articleType":"Research Article","associatedPublications":[],"authors":[{"id":618004042,"identity":"613b8dfb-fcef-4d99-9cee-bb5af3dd1050","order_by":0,"name":"Tian Lan","email":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAyAQMAAABI0h/eAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA10lEQVRIiWNgGAWjYBACfmb+B4Yffvzn4WdvPkCcFsl2HoZiyR5mGcmeYwnEaTE4z8PwgYeN2cbgRo4BkS47zHtwgwQPGw/DgZyPN94w2MnpNhDQwdjMl2xQYMHDw9hwdrPlHIZkY7MDBLQwMzOYGUjwSPAwM/ZukwbalbiNkBY2ZgbzHzxsBkDv8DwjTgsPM48BUH0CD9A7bMRpkWBmSzCW7DkAdBqbseUcAyL8Yn/+8AFgVB6wt7//+OGNNxV2cgS1oFrJQ2zUIGkhVccoGAWjYBSMCAAAy586PKLyh3gAAAAASUVORK5CYII=","orcid":"","institution":"Inner Mongolia University","correspondingAuthor":true,"prefix":"","firstName":"Tian","middleName":"","lastName":"Lan","suffix":""},{"id":618004043,"identity":"cd901a95-15c2-4465-992f-9e8ca7971602","order_by":1,"name":"Kaiyuan Xue","email":"","orcid":"","institution":"Inner Mongolia University","correspondingAuthor":false,"prefix":"","firstName":"Kaiyuan","middleName":"","lastName":"Xue","suffix":""},{"id":618004044,"identity":"c6cc376f-4759-41a8-b989-4c90a4e2f9e3","order_by":2,"name":"Ruyuan Duan","email":"","orcid":"","institution":"Inner Mongolia University","correspondingAuthor":false,"prefix":"","firstName":"Ruyuan","middleName":"","lastName":"Duan","suffix":""},{"id":618004045,"identity":"cae9c610-08db-49c0-90c9-e79a98e29590","order_by":3,"name":"Meng Sun","email":"","orcid":"","institution":"Inner Mongolia University","correspondingAuthor":false,"prefix":"","firstName":"Meng","middleName":"","lastName":"Sun","suffix":""}],"badges":[],"createdAt":"2026-03-23 02:55:01","currentVersionCode":1,"declarations":"","doi":"10.21203/rs.3.rs-9194820/v1","doiUrl":"https://doi.org/10.21203/rs.3.rs-9194820/v1","draftVersion":[],"editorialEvents":[],"editorialNote":"","failedWorkflow":false,"files":[{"id":106724963,"identity":"e93637d3-72b2-44b1-8a7c-f9fbb5420b10","added_by":"auto","created_at":"2026-04-12 18:30:47","extension":"pdf","order_by":1,"title":"","display":"","copyAsset":false,"role":"manuscript-pdf","size":854245,"visible":true,"origin":"","legend":"","description":"","filename":"testerevalnew.pdf","url":"https://assets-eu.researchsquare.com/files/rs-9194820/v1_covered_c57328a4-36a0-4ebf-a807-ba3351cfb3ad.pdf"}],"financialInterests":"No competing interests reported.","formattedTitle":"An Empirical Study on Pragmatic Unit Test Generation with Large Language Models","fulltext":[],"fulltextSource":"","fullText":"","funders":[],"hasAdminPriorityOnWorkflow":false,"hasManuscriptDocX":false,"hasOptedInToPreprint":true,"hasPassedJournalQc":"","hasAnyPriority":false,"hideJournal":false,"highlight":"","institution":"","isAcceptedByJournal":false,"isAuthorSuppliedPdf":true,"isDeskRejected":"","isHiddenFromSearch":false,"isInQc":false,"isInWorkflow":false,"isPdf":true,"isPdfUpToDate":true,"isWithdrawnOrRetracted":false,"journal":{"display":true,"email":"
[email protected]","identity":"software-quality-journal","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":false,"externalIdentity":"sqjo","sideBox":"Learn more about [Software Quality Journal](http://link.springer.com/journal/11219)","snPcode":"11219","submissionUrl":"https://submission.nature.com/new-submission/11219/3","title":"Software Quality Journal","twitterHandle":"","acdcEnabled":true,"dfaEnabled":true,"editorialSystem":"em","reportingPortfolio":"Springer Hybrid","inReviewEnabled":true,"inReviewRevisionsEnabled":false},"keywords":" Code Coverage, Unit Test Generation, Large Language Models, Benchmark","lastPublishedDoi":"10.21203/rs.3.rs-9194820/v1","lastPublishedDoiUrl":"https://doi.org/10.21203/rs.3.rs-9194820/v1","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"},"manuscriptAbstract":"Unit testing validates whether a program unit (e.g., a function or a class) under test behaves correctly. To alleviate manual efforts in writing unit test cases, researchers have proposed various techniques to facilitate automated unit test generation, including the use of deep learning techniques (such as large language models in short as LLMs). To fully assess the effectiveness of unit test cases generated based on LLMs, in this paper, we propose the extensible TesterEval benchmark, which comprehensively assesses the unit test cases' quality in terms of compilability, code coverage, bug-finding ability, and false-positive bug warnings. To produce a representative and diverse benchmark for tasks of unit test generation, we construct TesterEval based on CoderEval, a state-of-the-art benchmark that evaluates code generation models for realistic scenarios of code generation. We evaluate and compare five state-of-the-art models (WizardCoder, DeepSeekCoder, Codellama, ChatGPT, and GPT4) on TesterEval. Experimental results reveal four important findings: (1) ChatGPT outperforms GPT4 in terms of compilability, code coverage, bug findings, and false-positive bug warnings, (2) all models perform worse on a non-standalone function (i.e., a function that invokes or accesses at least one non-built-in/non-standard-library function defined outside this function) than on a standalone function, (3) it is important yet challenging for all models to generate unit tests when given no test context (e.g., the unit tests' belonging test class), and (4) all models perform similarly between (a) when given only natural language description and the name and signature of the focal function (i.e., the function under test) and (b) when given only the focal function's implementation, implying that LLMs may help alleviate the manual efforts for developers during test-driven development.","manuscriptTitle":"An Empirical Study on Pragmatic Unit Test Generation with Large Language Models","msid":"","msnumber":"","nonDraftVersions":[{"code":1,"date":"2026-04-09 22:52:32","doi":"10.21203/rs.3.rs-9194820/v1","editorialEvents":[{"type":"communityComments","content":0},{"type":"reviewersInvited","content":"","date":"2026-04-05T23:32:35+00:00","index":"","fulltext":""},{"type":"editorAssigned","content":"","date":"2026-03-28T08:22:15+00:00","index":"","fulltext":""},{"type":"checksComplete","content":"","date":"2026-03-26T02:11:11+00:00","index":"","fulltext":""},{"type":"submitted","content":"Software Quality Journal","date":"2026-03-23T02:47:11+00:00","index":"","fulltext":""}],"status":"published","journal":{"display":true,"email":"
[email protected]","identity":"software-quality-journal","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":false,"externalIdentity":"sqjo","sideBox":"Learn more about [Software Quality Journal](http://link.springer.com/journal/11219)","snPcode":"11219","submissionUrl":"https://submission.nature.com/new-submission/11219/3","title":"Software Quality Journal","twitterHandle":"","acdcEnabled":true,"dfaEnabled":true,"editorialSystem":"em","reportingPortfolio":"Springer Hybrid","inReviewEnabled":true,"inReviewRevisionsEnabled":false}}],"origin":"","ownerIdentity":"3fd36fec-4840-4409-b9fa-3c9d192244da","owner":[],"postedDate":"April 9th, 2026","published":true,"recentEditorialEvents":[],"rejectedJournal":[],"revision":"","amendment":"","status":"under-review","subjectAreas":[],"tags":[],"updatedAt":"2026-04-09T22:52:32+00:00","versionOfRecord":[],"versionCreatedAt":"2026-04-09 22:52:32","video":"","vorDoi":"","vorDoiUrl":"","workflowStages":[]},"version":"v1","identity":"rs-9194820","journalConfig":"researchsquare"},"__N_SSP":true},"page":"/article/[identity]/[[...version]]","query":{"redirect":"/article/rs-9194820","identity":"rs-9194820","version":["v1"]},"buildId":"XKTyCvWXoU3ODBz1xrDgd","isFallback":false,"isExperimentalCompile":false,"dynamicIds":[84888],"gssp":true,"scriptLoader":[]}
Text is read by the "Ask this paper" AI Q&A widget below.
Extraction quality varies by source — PMC NXML preserves structure
cleanly, OA-HTML may include some navigation residue, and OA-PDF can
have broken hyphenation. The publisher copy
(via DOI)
is the canonical version.