Computer Science ›› 2026, Vol. 53 ›› Issue (8): 365-374.doi: 10.11896/jsjkx.250900162

• Computer Software • Previous Articles     Next Articles

Test Case Generation and Prioritization for Program Fault Diagnosis Based on Large LanguageModel

FAN Ruxin1, SUN Baicai1, GONG Lina2, YAO Xiangjuan3, GONG Dunwei1   

  1. 1 School of Information Science and Technology, Qingdao University of Science and Technology, Qingdao, Shandong 266000, China
    2 School of Computer Science and Technology, Nanjing University of Aeronautics and Astronautics, Nanjing 220000, China
    3 School of Mathematics, China University of Mining and Technology, Xuzhou, Jiangsu 221000, China
  • Received:2025-09-28 Revised:2025-12-11 Online:2026-08-15 Published:2026-08-17
  • About author:FAN Ruxin,born in 2002,postgraduate.Her main research interests include software testing and test automation.
    GONG Dunwei,born in 1970,Ph.D,professor,Ph.D supervisor,is a member of CCF(No.31204D).His main research interests include intelligent optimization and software testing.
  • Supported by:
    Major Basic Research Project of Natural Science Foundation of Shandong Province(ZR2023ZD06) and National Natural Science Foundation of China(62302502).

Abstract: In recent years,large language model(LLM) have been widely applied to test case generation and prioritization.However,existing studies show that LLM-generated test cases still suffer from high error rates and semantic deviations.Empirical evaluations indicate that only about 40% of the generated code is directly executable,with roughly one-third of the failures caused by assertion logic errors.These issues significantly undermine the effectiveness and reliability of LLM-based fault diagnosis.To address this problem,this paper proposes a fault diagnosis-oriented test case generation and prioritization method based on LLM.Firstly,the proposed approach extracts code summaries from the original program using an LLM to generate substitute programs that implement equivalent functionality.Then,the LLM is employed to produce initial test cases,whose expected outputs are refined through multiple substitute programs.Next,the differences between the outputs of the original and substitute programs are analyzed,and test cases are prioritized based on the function call relationships of the original program.Finally,program faults are diagnosed efficiently according to the prioritized sequence.Experiments are conducted on seven benchmark problems comprising 140 Python programs.The results demonstrate that the proposed method significantly reduces the error rate of LLM-generated test cases.The resulting test sequences achieve high fault coverage across multiple LLM,with an average fault detection rate(APFD) consistently above 0.75,confirming the proposed method’s effectiveness in improving test accuracy and fault diagnosis efficiency.

Key words: Large language model, Program fault detection, Test case generation, Test case prioritization

CLC Number: 

  • TP301
[1] BAREJA K,SINGHAL A.A review of estimation techniques to reduce testing efforts in software development[C]//2015 Fifth International Conference on Advanced Computing & Communication Technologies.IEEE,2015:541-546.
[2] LI K,YUAN Y.Large language models as test case generators:Performance evaluation and enhancement[PP/OL].arXiv[2025-03-20].https://arxiv.org/abs/2404.13340.
[3] MATTIS T,BÖHME L,KREBS E,et al.Faster Feedback with AI? A Test Prioritization Study[C]//Companion Proceedings of the 8th International Conference on the Art,Science,and Engineering of Programming.2024:32-40.
[4] WANG C,PASTORE F,GOKNIL A,et al.Automatic generation of system test cases from use case specifications[C]//Proceedings of the 2015 International Symposium on Software Testing and Analysis.2015:385-396.
[5] LIU J,XIA C S,WANG Y,et al.Is your code generated by chatgpt really correct? Rigorous evaluation of large language models for code generation[J].Advances in Neural Information Processing Systems,2023,36:21558-21572.
[6] BALDONI R,COPPA E,D’ELIA D C,et al.A survey of symbolic execution techniques[J].ACM Computing Surveys(CSUR),2018,51(3):1-39.
[7] JIA Y,HARMAN M.An analysis and survey of the development of mutation testing[J].IEEE Transactions on Software Engineering,2010,37(5):649-678.
[8] PRADEL M,SEN K.Deepbugs:A learning approach to name-based bug detection[J].Proceedings of the ACM on Programming Languages,2018,2(OOPSLA):1-25.
[9] HOSSAIN S B,JIANG N,ZHOU Q,et al.A deep dive into large language models for automated bug localization and repair[J].Proceedings of the ACM on Software Engineering,2024,1(FSE):1471-1493.
[10] SIDDIQ M L,DA SILVA SANTOS J C,TANVIR R H,et al.Using large language models to generate junit tests:An empirical study[C]//Proceedings of the 28th International Conference on Evaluation and Assessment in Software Engineering.2024:313-322.
[11] SAHOO P,SINGH A K,SAHA S,et al.A systematic survey of prompt engineering in large language models:Techniques and applications[PP/OL].arXiv[2025-03-20].https://arxiv.org/abs/2402.07927.
[12] SCHÄFER M,NADI S,EGHBALI A,et al.An empirical evaluation of using large language models for automated unit test generation[J].IEEE Transactions on Software Engineering,2023,50(1):85-105.
[13] WANG Y,ZI Q C,PENG X,et al.A Method for Generating Fault Reproduction Test Cases Based on Large Language Mo-dels[J].Ruan Jian Xue Bao/Journal of Software,2026,37(4):1690-1714.
[14] XIAO Z Q,SHI Y Q,QU Y B.Research on Optimization of Test Case Generation Based on Neuron Coverage Indicators[J].Computer Science,2025,52(11):339-348.
[15] HOODA I,CHHILLAR R S.Test case optimization and redundancy reduction using GA and neural networks[J].International Journal of Electrical and Computer Engineering,2018,8(6):5449-5457.
[16] ELBAUM S,MALISHEVSKY A G,ROTHERMEL G.Prioritizing test cases for regression testing[C]//Proceedings of the International Symposium on Software Testing and Analysis.2000:102-112.
[17] LI Z,HARMAN M,HIERONS R M.Search algorithms for regression test case prioritization[J].IEEE Transactions on Software Engineering,2007,33(4):225-237.
[18] TONELLA P,AVESANI P,SUSI A.Using the case-basedranking methodology for test case prioritization[C]//2006 22nd IEEE International Conference on Software Maintenance.IEEE,2006.
[19] LACHMANN R,SCHULZE S,NIEKE M,et al.System-level test case prioritization using machine learning[C]//2016 15th IEEE International Conference on Machine Learning and Applications(ICMLA).IEEE,2016.
[20] SHARIF A,MARIJAN D,LIAAEN M.Deeporder:Deep lear-ning for test case prioritization in continuous integration testing[C]//2021 IEEE International Conference on Software Maintenance and Evolution(ICSME).IEEE,2021.
[21] LI Y,LI M,LAI Q,et al.Testrank:Bringing order into unlabeled test instances for deep learning tasks[J].Advances in Neural Information Processing Systems,2021,34:20874-20886.
[22] LI T O,ZONG W,WANG Y,et al.Nuances are the key:Unlo-cking chatgpt to find failure-inducing tests with differential prompting[C]//2023 38th IEEE/ACM International Confe-rence on Automated Software Engineering(ASE).IEEE,2023:14-26.
[23] CODEFORCES.Codeforces[EB/OL].[2025-03-20].https://codeforces.com/.
[24] OPENAI.GPT-4[EB/OL].[2025-03-20].https://openai.com/zh-Hans-CN/index/gpt-4/.
[25] META.Llama[EB/OL].[2025-03-20].https://www.llama-cn.com/.
[26] ANTHROPIC.Claude AI[EB/OL].[2025-03-20].https://claude.ai/login.
[1] JIA Zishuo, ZHANG Jian’ge, HE Haofeng, FENG Shizhong, LIU Yilin. Survey on Mutually Augmenting Technologies and Applications of Large Models and KnowledgeGraphs [J]. Computer Science, 2026, 53(8): 219-228.
[2] LIU Jing. Review of Music Artificial Intelligence Driven by Large Language Models [J]. Computer Science, 2026, 53(8): 229-244.
[3] ZHANG Haoran, HAO Wenning, JIN Dawei, CHENG Kai, LIU Junyang. Agentic Retrieval Augmented Generation Framework Based on Retrieval Task Planning and Reflection Mechanism [J]. Computer Science, 2026, 53(8): 285-297.
[4] ZHANG Zhonglin, XIA Hang. LSQ-RAG:Retrieval-enhanced Generation Framework Based on LLM-enhanced Ranker [J]. Computer Science, 2026, 53(8): 298-306.
[5] WANG Xinlin, LI Yan, MA Chaofan, LI Shuo. Retrieval-Augmented Generation:Survey of Methods and Applications [J]. Computer Science, 2026, 53(7): 101-117.
[6] CHEN Zhixiang, XIE Zhipeng. Event Causal Data Augmentation Method Based on Large Language Model [J]. Computer Science, 2026, 53(7): 125-131.
[7] XU Rui, LIU Jin, LIU Xudong, GUAN Jian, DONG Wei. Exploring the Generalization Ability of Prompt-based Large Language Models for TextClassification [J]. Computer Science, 2026, 53(6A): 250400092-7.
[8] WEI Qing, ZHANG Yupeng, LIU Shaoxun, ZHANG Jinfeng, ZHANG Yuezhong, CHEN Haoyang. Fuzzing Driver Generation Based on Large Language Models [J]. Computer Science, 2026, 53(6A): 250400113-8.
[9] ZHANG Yongyu, GUO Chenjuan, FEI Xueqin, LI Feng. Study on Financial Text Sentiment Analysis Method Based on Large Language Models with Market Feedback Supervision [J]. Computer Science, 2026, 53(6A): 250500073-14.
[10] LIU Jiaqi, GAO Zhizezhang, MENG Xianjia, SUN Xia, FENG Jun. Automatic Knowledge Point Annotation for Student Code Based on Multi-agent Collaboration:A Case Study of C Language [J]. Computer Science, 2026, 53(6): 59-68.
[11] SHI Hongxu, LIU Yi, LIU Kun. Survey of Recommendation Systems Based on Large Language Models [J]. Computer Science, 2026, 53(6): 281-303.
[12] WANG Shenghui, LI Teng. Innovative Automated Scoring Based on Large Language Models [J]. Computer Science, 2026, 53(5): 90-98.
[13] JI Wendi, WANG Yongquan, SHEN Yicheng. Boosting Generative Rule Extraction via Negative-aware Approach [J]. Computer Science, 2026, 53(5): 276-285.
[14] HAN Linrui, ZHENG Ri, CONG Yingnan. Explainable Sentencing Prediction Method Driven by Sentencing Rule Knowledge Graph [J]. Computer Science, 2026, 53(5): 286-298.
[15] LIU Xukai, LIU Yang, HUANG Haozhen. EC-MIIP:Efficient Fine-tuning Small-parameter Large Language Model for Intellectual Property [J]. Computer Science, 2026, 53(5): 299-308.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!