Lune

ASE2024Top-tier venue

HITS: High-coverage LLM-based Unit Test Generation via Method Slicing

Zejun Wang, Kaibo Liu, Ge Li, Zhi Jin

Abstract

Large language models (LLMs) have behaved well in generating unit tests for Java projects. However, the performance for covering the complex focal methods within the projects is poor. Complex methods comprise many conditions and loops, requiring the test cases to be various enough to cover all lines and branches. However, existing test generation methods with LLMs provide the whole method-to-test to the LLM without assistance on input analysis. The LLM has difficulty inferring the test inputs to cover all conditions, resulting in missing lines and branches. To tackle the problem, we propose decomposing the focal methods into slices and asking the LLM to generate test cases slice by slice. Our method simplifies the analysis scope, making it easier for the LLM to cover more lines and branches in each slice. We build a dataset comprising complex focal methods collected from the projects used by existing state-ofthe-art approaches. Our experiment results show that our method significantly outperforms current test case generation methods with LLMs and the typical SBST method Evosuite regarding both line and branch coverage scores.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

22 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Knowledge Matters: Injecting Project and Testing Knowledge into LLM-based Unit Test Generation cites CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language Models
  • Knowledge Matters: Injecting Project and Testing Knowledge into LLM-based Unit Test Generation cites Code-Aware Prompting: A Study of Coverage-Guided Test Generation in Regression Setting using LLM
  • LLM Test Generation via Iterative Hybrid Program Analysis cites CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language Models
  • LLM Test Generation via Iterative Hybrid Program Analysis cites CAT-LM Training Language Models on Aligned Code And Tests
  • LLM Test Generation via Iterative Hybrid Program Analysis cites Code-Aware Prompting: A Study of Coverage-Guided Test Generation in Regression Setting using LLM
  • Unit Test Update through LLM-Driven Context Collection and Error-Type-Aware Refinement cites Code-Aware Prompting: A Study of Coverage-Guided Test Generation in Regression Setting using LLM
  • Teaching Large Language Models to Self-Debug cites Self-Refine: Iterative Refinement with Self-Feedback
  • Code-Aware Prompting: A Study of Coverage-Guided Test Generation in Regression Setting using LLM cites CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language Models
  • UTFix: Change Aware Unit Test Repairing using LLM cites Code-Aware Prompting: A Study of Coverage-Guided Test Generation in Regression Setting using LLM
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers22

  1. UTFix: Change Aware Unit Test Repairing using LLMShanto Rahman, Sachit Kuhar, Berk Çirisci, Pranav Garg et al.OOPSLA 2025 · 9 citations
  2. LLM Test Generation via Iterative Hybrid Program AnalysisSijia Gu, Noor Nashid, Ali MesbahICSE 2026 · 6 citations
  3. FidelityGPT: Correcting Decompilation Distortions with Retrieval Augmented GenerationZhiping Zhou, Xiaohong Li, Ruitao Feng, Yao Zhang et al.NDSS 2026 · 5 citations
  4. Unit Test Update through LLM-Driven Context Collection and Error-Type-Aware RefinementYuanhe Zhang, Zhiquan Yang, Shengyi Pan, Zhongxin LiuASE 2025 · 3 citations
  5. Knowledge Matters: Injecting Project and Testing Knowledge into LLM-based Unit Test GenerationAnji Li, Mingwei Liu, Zhenxi Chen, Zheng Pei et al.ICSE 2026 · 2 citations

Builds on6

  1. Self-Refine: Iterative Refinement with Self-FeedbackAman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan et al.NeurIPS 2023 · 4,972 citations
  2. Teaching Large Language Models to Self-DebugXinyun Chen, Maxwell Lin, Nathanael Schärli, Denny ZhouICLR 2024 · 1,085 citations
  3. CodaMosa: Escaping Coverage Plateaus in Test Generation with Pre-trained Large Language ModelsCaroline Lemieux, Jeevana Priya Inala, Shuvendu K. Lahiri, Siddhartha SenICSE 2023 · 221 citations
  4. Code-Aware Prompting: A Study of Coverage-Guided Test Generation in Regression Setting using LLMGabriel Ryan, Siddhartha Jain, Mingyue Shang, Shiqi Wang et al.FSE 2024 · 68 citations
  5. CAT-LM Training Language Models on Aligned Code And TestsNikitha Rao, Kush Jain, Uri Alon, Claire Le Goues et al.ASE 2023 · 37 citations

Related papers

  1. Do LLMs Generate Useful Test Oracles? An Empirical Study with an Unbiased DatasetDavide Molinelli, Luca Di Grazia, Alberto Martin-Lopez, Michael D. Ernst et al.ASE 2025 · 3 citations
  2. On the Evaluation of Large Language Models in Unit Test GenerationLin Yang, Chen Yang, Shutao Gao, Weijing Wang et al.ASE 2024 · 42 citations
  3. Navigating the Labyrinth: Path-Sensitive Unit Test Generation with Large Language ModelsDianshu Liao, Xin Yin, Shidong Pan, Chao Ni et al.ASE 2025 · 2 citations
  4. Test Intention Guided LLM-Based Unit Test GenerationZifan Nan, Zhaoqiang Guo, Kui Liu, Xin XiaICSE 2025 · 5 citations
  5. TOGLL: Correct and Strong Test Oracle Generation with LLMSSoneya Binta Hossain, Matthew B. DwyerICSE 2025 · 12 citations
Dusk over the sea between two cliffs drawn in fine vertical lines