Automated Test Generation for Hard-to-Cover Code Branches

26 concepts17 papers1 proposal

Automated testing tools promise a hands-off approach to software quality. Whether relying on random fuzzing, dynamic symbolic execution (DSE), or modern Large Language Models (LLMs), the goal is to maximize code coverage and uncover hidden bugs. However, in practice, these tools frequently hit a wall, often leaving more than half of a program's branches unexecuted.

As noted by Chen Yang et al. in their work on Advancing Code Coverage: Incorporating Program Analysis with Large Language Models, upwards of 60% of software branches are "hard-to-cover" using standard automated techniques. To bridge this gap, a major research direction focuses on understanding why these branches remain out of reach and designing mechanisms to systematically navigate complex program states.

The Core Challenge: The Object State Bottleneck

Why do automated tools get stuck? In object-oriented systems, executing a specific branch often requires an input object to be in a highly precise, complex state. To reach that state, a test generator cannot simply pass random primitive values; it must execute a specific sequence of method calls in a precise order.

Suresh Thummalapenta et al. demonstrate this challenge in MSeqGen: object-oriented unit-test generation via mining source code, explaining that the search space for these sequences is astronomically large. If a branch is guarded by a condition that depends on an intricate graph configuration or a multi-step object initialization, random or symbolic approaches face a combinatorial explosion. They fail to generate the required object instances, leading to incomplete test suites and missed bugs.

Strategy 1: Bootstrapping from Real-World Code and Executions

Instead of guessing method sequences blindly, one powerful intuition is to look at how objects are naturally constructed by developers or real users.

Mining Existing Codebases

In MSeqGen, Suresh Thummalapenta et al. propose mining existing codebases to observe how developers actually initialize and manipulate objects. By extracting these real-world method call sequences, the test generator leverages human intelligence implicitly embedded in the codebase. Instead of searching a combinatorial space, it copies sequences known to produce valid states, significantly boosting structural coverage.

Capturing and Mutating Runtime Objects

Taking this a step further, Hojun Jaygarl et al. introduced OCAT in OCAT: object capture-based automated testing. Rather than synthesizing sequences statically, OCAT captures fully-formed, real-world object instances directly from actual program executions.

[ Real Program Execution ] ---> Capture Healthy Object State (Invariants Satisfied)
                                       |
                                       v
[ Hard-to-Cover Branch ]   <--- Mutate Object Slightly <--- [ Test Generation Tool ]

This completely sidesteps the sequence generation problem. If an object requires dozens of method calls to reach a valid state, capturing it at runtime gives you that state for free. The tool then applies small mutations to these captured objects to push the execution into previously unreachable edge-case branches.

Strategy 2: Pruning and Mapping via Program Analysis

Another core strategy relies on combining static analysis with dynamic execution to build a "map" of the program's logic, ensuring the testing tool does not waste computational resources on dead ends.

In Synthesizing method sequences for high-coverage testing, Suresh Thummalapenta et al. present Seeker, a tool that dynamically refines static insights. Static analysis identifies which methods modify the fields required by a target branch, while dynamic execution tries out these sequences and refines the primitive arguments.

For systems with complex conditional logic, traditional symbolic execution engines get bogged down solving constraints for paths that can never reach the target. To solve this, Ashutosh Gupta et al. developed CRABS in Abstraction-driven Concolic Testing. CRABS uses model checking to iteratively build an abstract "monitor" of the program. This monitor prunes away impossible execution paths early, allowing the concolic engine to focus its constraint-solving budget exclusively on paths that can actually reach uncovered branches.

Strategy 3: Guiding Modern Generative and Neural Models

As testing expands to mobile user interfaces and Large Language Models, the nature of "hard-to-cover" branches shifts, but the underlying state-space problem remains identical.

Bypassing UI Tarpits

In mobile app testing, automated tools often get trapped in complex screens (such as login walls or multi-step forms) that prevent them from exploring the rest of the application. Safwat Ali Khan et al. address this in AURORA: Navigating UI Tarpits via Automated Neural Screen Understanding. By training neural networks to understand common UI design patterns, their tool recognizes and intelligently bypasses these "tarpits," unlocking the deep, functional branches of the application that lie behind them.

Enhancing LLMs with Semantic Context

While LLMs are excellent at writing human-like code, surveys like Software Testing With Large Language Models: Survey, Landscape, and Vision by Junjie Wang 0001 et al. show that LLMs alone often fail to achieve high structural coverage because they lack deep semantic awareness of inter-procedural dependencies.

To fix this, Chen Yang et al. developed TELPA (Advancing Code Coverage: Incorporating Program Analysis with Large Language Models), which feeds precise contextual information from program analysis back into the LLM prompt. By giving the LLM a clear recipe of the required object constructions and method dependencies, it bridges the gap between creative test generation and strict structural coverage requirements.

Key Foundational Work

MSeqGen: object-oriented unit-test generation via mining source code (2009) — contributed 4 concept elements to this direction.
OCAT: object capture-based automated testing (2010) — contributed 2 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_limited_code_coverage_2736b7f0,
  title = {limited code coverage},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/limited-code-coverage/rdr_2736b7f006b241b5974ed8c71a01225c},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-25},
}

This exact version (version 1, frozen text):

@misc{lacuna_limited_code_coverage_2736b7f0_v1,
  title = {limited code coverage},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/limited-code-coverage/rdr_2736b7f006b241b5974ed8c71a01225c/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-25},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake