[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-86267-en":3,"doc-seo-86267-105":30,"detail-sidebar-cat-0-en-105":92},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":20,"is_deleted":4,"is_public":21,"is_downloadable":21,"audit_status":21,"page_count":22,"language":23,"language_code":24,"site_id":25,"html_lang":24,"table_of_contents":26,"faqs":27,"seo_title":13,"seo_description":14,"update_tm":28,"read_time":29},86267,687197207919,"Theodora","https://ap-avatar.wpscdn.com/avatar/a000253d6f5f7c60be?x-image-process=image/resize,m_fixed,w_180,h_180&k=1779446848396160552",8,"Research & Report","Knowledge Guided Synthetic Bug Feedback for LLM Based Unit Test Generation","Large language models enable automatic unit test generation, yet executable tests often fail to expose real defects. This paper proposes a framework that converts historical real-bug mechanisms into executable feedback targets. It builds structural and semantic representations of real-bug records, retrieves mechanisms relevant to a focal method, and instantiates them as synthetic bugs for iterative test enhancement. Experiments on Defects4J method-level real-bug detection show mechanism-guided synthetic-bug feedback improves detection over execution, coverage, mutation, knowledge, and search baselines.","Knowledge-Guided Synthetic Bug Feedback for LLM-Based Unit Test Generation  \nZiheng Wang, Maike Li, Chen Zhi  \nZhejiang University  \nEmail: {zihwang,22451156,[zjuzhichen](zjuzhichen}@zju.edu.cn)[}](zjuzhichen}@zju.edu.cn)[@zju.edu.cn](zjuzhichen}@zju.edu.cn)  \narXiv :2607 . 1 1573v 1 [ cs . SE] 13 Jul 2026  \nAbstract—Large language models (LLMs) have opened new opportunities for unit test generation, but executable tests do not necessarily reveal real defects. This paper studies how historical real-bug mechanisms can be transformed into executable feedback targets for LLM-based unit test generation. The proposed framework constructs structural and semantic representations of real-bug records, retrieves mechanisms applicable to a focal method, and instantiates them as synthetic bugs that guide iterative test enhancement. We evaluate the approach on methodlevel real-bug detection tasks from Defects4J and show that mechanism-guided synthetic-bug feedback improves real-bug detection over execution-, coverage-, mutation-, knowledge-, and search-based baselines. The results suggest that organizing realbug mechanisms as retrievable and executable feedback targets is an effective way to guide generated tests toward bug-triggering inputs and behavioral oracles.  \nIndex Terms—LLM-based unit test generation, synthetic bug injection, real-bug detection, repository knowledge  \nI. INTRODUCTION  \nUnit testing is a fundamental technique for detecting regression defects and validating program behavior. Automated test generation has long explored random testing [1], searchbased testing [2]–[4], and symbolic execution and its hybrid variants [5]–[8] . Recent LLM-based methods further synthesize test code from a focal method, repository context, or natural-language intent [9], [10], and improve compilability and project adaptation by leveraging repository knowledge or language-specific constraints [11]–[13] . However, compilable and executable tests do not necessarily reveal defects. For regression detection, generated tests must not only execute the target code, but also trigger bug-relevant behavior, include effective oracles, and distinguish correct behavior from buggy behavior [14] .  \nTo improve generated tests beyond one-shot prompting, existing LLM-based methods introduce feedback into the generation loop. Execution-feedback methods repair candidate tests using compilation errors, runtime failures, or invalid assertions [15], [16] . Coverage-guided methods prompt the model to exercise uncovered statements or branches [17], [18], while mutation-guided methods use surviving mutants as stronger feedback targets [19]–[22] . These signals are measurable and automatable, but they remain proxy objectives for real-bug detection: a test may cover target code without checking the critical semantic boundary, or kill generic mutants without triggering the input conditions on which a real bug depends. Fig. 1 and Fig. 2 illustrate this mismatch using CSVFormat\\#printAndQuote(...) in Apache Commons CSV. Under the  \nMINIMAL quote mode, the method checks whether characters in a field fall within the RFC4180 TEXTDATA range and decides whether the field should be quoted. The real bug concerns the safe range of the first character: for a single backslash \\ (0x5C), the correct version should emit the character without quotes, whereas the buggy version emits a quoted result. Detecting this bug requires entering the quote-decision logic, constructing an input on the safe-character boundary, and asserting the exact serialized output.  \nIn Fig. 1, CoverUp enters the MINIMAL branch and covers the quote-decision logic, but it does not generate an oracle for the safe-character boundary. In Fig. 2, MutGen kills several local mutants and improves mutation score from 0.40 to 0.75, but these mutants mainly encode local perturbations rather than the bug mechanism. Coverage and generic mutation can strengthen tests, but they do not necessarily provide mechanism-level infor","cbCaiingE6EOCrek","https://ap.wps.com/l/cbCaiingE6EOCrek","pdf",965749,6,1,12,"English","en",105,"# Introduction\n## Motivation: limitations of proxy feedback signals\n## Framework idea: transforming real-bug mechanisms into executable feedback\n## Challenges: representation, generalization, and injection","[{\"question\":\"Why do compilation- and execution-successful generated tests fail to reliably find real defects?\",\"answer\":\"Because tests may execute the target code and even satisfy measurable proxy objectives, while not triggering the semantic boundary and behavioral oracle required for the real bug to manifest.\"},{\"question\":\"What does the proposed framework do with historical real-bug records?\",\"answer\":\"It abstracts them into transferable bug mechanisms by capturing applicability conditions and observable behavioral differences, then instantiates the retrieved mechanisms as synthetic bugs to guide iterative test improvement.\"},{\"question\":\"How is mechanism-guided synthetic-bug feedback evaluated and what is the result?\",\"answer\":\"The approach is evaluated on method-level real-bug detection tasks from Defects4J and shows improved real-bug detection compared with execution-, coverage-, mutation-, knowledge-, and search-based baselines.\"}]",1784209928,30,{"code":4,"msg":31,"data":32},"ok",{"site_id":25,"language":24,"slug":33,"title":13,"keywords":34,"description":14,"schema_data":35,"social_meta":87,"head_meta":89,"extra_data":91,"updated_unix":28},"knowledge-guided-synthetic-bug-feedback-for-llm-based-unit-test-generation","",{"@graph":36,"@context":86},[37,54,69],{"@type":38,"itemListElement":39},"BreadcrumbList",[40,44,48,51],{"item":41,"name":42,"@type":43,"position":21},"https://docshare.wps.com","Home","ListItem",{"item":45,"name":46,"@type":43,"position":47},"https://docshare.wps.com/document/","Document",2,{"item":49,"name":12,"@type":43,"position":50},"https://docshare.wps.com/document/research-report/",3,{"item":52,"name":13,"@type":43,"position":53},"https://docshare.wps.com/document/knowledge-guided-synthetic-bug-feedback-for-llm-based-unit-test-generation/86267/",4,{"url":52,"name":13,"@type":55,"author":56,"headline":13,"publisher":58,"fileFormat":61,"inLanguage":24,"description":14,"dateModified":62,"datePublished":63,"encodingFormat":61,"isAccessibleForFree":64,"interactionStatistic":65},"DigitalDocument",{"name":9,"@type":57},"Person",{"url":41,"name":59,"@type":60},"DocShare","Organization","application/pdf","2026-07-27","2026-07-16",true,{"@type":66,"interactionType":67,"userInteractionCount":20},"InteractionCounter",{"@type":68},"ViewAction",{"@type":70,"mainEntity":71},"FAQPage",[72,78,82],{"name":73,"@type":74,"acceptedAnswer":75},"Why do compilation- and execution-successful generated tests fail to reliably find real defects?","Question",{"text":76,"@type":77},"Because tests may execute the target code and even satisfy measurable proxy objectives, while not triggering the semantic boundary and behavioral oracle required for the real bug to manifest.","Answer",{"name":79,"@type":74,"acceptedAnswer":80},"What does the proposed framework do with historical real-bug records?",{"text":81,"@type":77},"It abstracts them into transferable bug mechanisms by capturing applicability conditions and observable behavioral differences, then instantiates the retrieved mechanisms as synthetic bugs to guide iterative test improvement.",{"name":83,"@type":74,"acceptedAnswer":84},"How is mechanism-guided synthetic-bug feedback evaluated and what is the result?",{"text":85,"@type":77},"The approach is evaluated on method-level real-bug detection tasks from Defects4J and shows improved real-bug detection compared with execution-, coverage-, mutation-, knowledge-, and search-based baselines.","https://schema.org",{"og:url":52,"og:type":88,"og:title":13,"og:site_name":59,"og:description":14},"article",{"robots":90,"canonical":52},"index,follow",{"doc_id":7,"site_id":25},{"code":4,"msg":5,"data":93},[94,98,102,106,111,115,120,122,127,130,134],{"id":21,"doc_module":4,"doc_module_name":46,"category_name":95,"show_sort_weight":96,"slug":97},"Story & Novel",90,"story-novel",{"id":47,"doc_module":4,"doc_module_name":46,"category_name":99,"show_sort_weight":100,"slug":101},"Literature",80,"literature",{"id":53,"doc_module":4,"doc_module_name":46,"category_name":103,"show_sort_weight":104,"slug":105},"Exam",70,"exam",{"id":107,"doc_module":4,"doc_module_name":46,"category_name":108,"show_sort_weight":109,"slug":110},5,"Comic",60,"comic",{"id":20,"doc_module":4,"doc_module_name":46,"category_name":112,"show_sort_weight":113,"slug":114},"Technology",50,"technology",{"id":116,"doc_module":4,"doc_module_name":46,"category_name":117,"show_sort_weight":118,"slug":119},7,"Healthcare",40,"healthcare",{"id":11,"doc_module":4,"doc_module_name":46,"category_name":12,"show_sort_weight":29,"slug":121},"research-report",{"id":123,"doc_module":4,"doc_module_name":46,"category_name":124,"show_sort_weight":125,"slug":126},9,"Religion & Spirituality",20,"religion-spirituality",{"id":125,"doc_module":4,"doc_module_name":46,"category_name":128,"show_sort_weight":125,"slug":129},"World Cup","world-cup",{"id":131,"doc_module":4,"doc_module_name":46,"category_name":132,"show_sort_weight":131,"slug":133},10,"Lifestyle","lifestyle",{"id":135,"doc_module":4,"doc_module_name":46,"category_name":136,"show_sort_weight":107,"slug":137},19,"General","general"]