Reconstructing Objects for Software Testing
Software testing requires developers to build nontrivial object states to thoroughly exercise programs that process data structures. Manually building these test cases is an effort-demanding activity. The execution of software in production is an enormous source of program states, which can be serialized to synthesize test inputs. Unfortunately, most serialization approaches prioritize performance over transparency, making it difficult to generate useful and maintainable test cases. We present X2J , an approach that captures objects from runtime and automatically generates human-readable code that reconstructs those objects. X2J leverages Large Language Models, enhanced with an AST-aware Retrieval-Augmented Generation component, and an iterative Validation-Driven Repair pipeline that seamlessly aligns the generated code with the captured state. We evaluated X2J across two benchmarks that include 10,794 objects from 21 Java projects, achieving \(80.7\%\) reconstruction accuracy, that significantly outperforms ProDJ , the closest approach based on program analysis, and six LLM baselines. We further validated X2J on a closed-source industrial application, and X2J achieved \(89.5\%\) accuracy, which confirms the results obtained using open-source software and supports the practical applicability of the approach. Overall, our evaluation shows that X2J successfully transforms production objects into maintainable test cases, thereby enhancing the efficiency and effectiveness of software testing.
Authors
- Luca Di Grazia (ORCID: https://orcid.org/0000-0002-5306-8645)
- Mattia Fazzini (ORCID: https://orcid.org/0000-0002-1412-1546)
- Mauro Pezzè (ORCID: https://orcid.org/0000-0001-5193-7379)
- Alessio Gambi (ORCID: https://orcid.org/0000-0002-0132-6497)
- Ketai Qiu (ORCID: https://orcid.org/0009-0002-9750-2762)
Institutions
- University of Minnesota (US)
- AIT Austrian Institute of Technology GmbH (AT)
- University of St.Gallen (CH)
- The Italian Institute of Artificial Intelligence (IT)
- Università della Svizzera italiana (CH)
- University of Milano-Bicocca (IT)
Publication Details
- Journal
- ACM Transactions on Software Engineering and Methodology
- Published
- 2026-11-20
- DOI
- https://doi.org/10.1145/3864372
- Primary Topic
- Software Testing and Debugging Techniques
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- National Science Foundation
- European Commission
- Schweizerischer Nationalfonds zur Förderung der Wissenschaftlichen Forschung