Introduction
Testing third-party library APIs presents a significant challenge due to the "infinite input" problem. APIs often require complex objects as parameters, where code behavior hinges on specific internal states that are difficult for automated tools to reach. Traditional approaches like search-based testing (e.g., EvoSuite) often generate redundant, invalid inputs, while symbolic execution struggles to scale with complex heap structures and native code.
This paper introduces LISP (LLM-based Input Space Partitioning), a novel framework that leverages Large Language Models (LLMs) to "understand" API semantics and partition the input space into meaningful categories, mimicking the intuition of an experienced human tester.
Methodology
LISP decomposes the test generation process into three distinct LLM-guided stages to ensure structural and semantic depth:
- Input Space Partitioning: Instead of immediate code generation, LISP provides the API's source code to an LLM and asks it to describe textual categories of inputs that trigger different behaviors (e.g., identifying "negative base with fractional exponent" for a power function).
- Top-down Type Dependency Analysis: To handle complex objects, LISP constructs a Type Dependency Graph (TDG). It recursively prompts the LLM to select the most appropriate constructors for nested objects based on the textual descriptions from the first stage.
- Bottom-up Object Instantiation: Finally, the LLM populates these selected constructors with concrete values (e.g.,
1.0f,0.0f) to produce a runnable test driver.
The researchers also evaluated LISP-CG, a variant that incorporates the source code of called methods via a call graph to provide the LLM with deeper execution context.
Evaluation and Results
The framework was evaluated on a large-scale dataset of 2,205 API methods from 10 popular open-source Java libraries, including Google Guava and Apache Commons.
- Superior Coverage: LISP achieved an average branch coverage of 67.82%, outperforming the state-of-the-art tool EvoSuite by 1.21x.
- Vulnerability Discovery: The tool triggered 404 unique exceptions and successfully uncovered 13 previously unknown vulnerabilities that were subsequently assigned CVE IDs.
- Efficiency: While LISP generates fewer total inputs than search-based tools, its inputs are of significantly higher quality. The coverage improvement per input is roughly 4 to 7 times higher than that of EvoSuite.
- Ablation Study: Removing the initial partitioning step caused coverage to plummet from ~67% to ~32%, confirming that semantic partitioning is the core driver of the framework's success.
Discussion and Future Work
The success of LISP highlights the potential of LLMs as "semantic bridges" in software testing. By training on both code and technical documentation, LLMs can identify corner cases (like $0^0$) that purely structural tools might miss. The structured "Chain-of-Thought" approach—partitioning before generation—is critical for reducing hallucinations and ensuring diverse test coverage.
However, limitations remain. Currently, LISP focuses on single API calls and does not yet handle complex sequences of interactions. Furthermore, approximately 50% of generated inputs were unrunnable, indicating a need for better "hit rate" optimization. Future research will explore Retrieval-Augmented Generation (RAG) to integrate external documentation like Javadocs directly into the prompting process.
Summary updated