Mutation Testing via Iterative Large Language Model-Driven Scientific Debugging

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Straubinger, Philipp, Kreis, Marvin, Lukasczyk, Stephan, Fraser, Gordon
Natura: Preprint
Pubblicazione: 2025
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866917951310921728
author Straubinger, Philipp
Kreis, Marvin
Lukasczyk, Stephan
Fraser, Gordon
author_facet Straubinger, Philipp
Kreis, Marvin
Lukasczyk, Stephan
Fraser, Gordon
contents Large Language Models (LLMs) can generate plausible test code. Intuitively they generate this by imitating tests seen in their training data, rather than reasoning about execution semantics. However, such reasoning is important when applying mutation testing, where individual tests need to demonstrate differences in program behavior between a program and specific artificial defects (mutants). In this paper, we evaluate whether Scientific Debugging, which has been shown to help LLMs when debugging, can also help them to generate tests for mutants. In the resulting approach, LLMs form hypotheses about how to kill specific mutants, and then iteratively generate and refine tests until they succeed, all with detailed explanations for each step. We compare this method to three baselines: (1) directly asking the LLM to generate tests, (2) repeatedly querying the LLM when tests fail, and (3) search-based test generation with Pynguin. Our experiments evaluate these methods based on several factors, including mutation score, code coverage, success rate, and the ability to identify equivalent mutants. The results demonstrate that LLMs, although requiring higher computation cost, consistently outperform Pynguin in generating tests with better fault detection and coverage. Importantly, we observe that the iterative refinement of test cases is important for achieving high-quality test suites.
format Preprint
id arxiv_https___arxiv_org_abs_2503_08182
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Mutation Testing via Iterative Large Language Model-Driven Scientific Debugging
Straubinger, Philipp
Kreis, Marvin
Lukasczyk, Stephan
Fraser, Gordon
Software Engineering
Large Language Models (LLMs) can generate plausible test code. Intuitively they generate this by imitating tests seen in their training data, rather than reasoning about execution semantics. However, such reasoning is important when applying mutation testing, where individual tests need to demonstrate differences in program behavior between a program and specific artificial defects (mutants). In this paper, we evaluate whether Scientific Debugging, which has been shown to help LLMs when debugging, can also help them to generate tests for mutants. In the resulting approach, LLMs form hypotheses about how to kill specific mutants, and then iteratively generate and refine tests until they succeed, all with detailed explanations for each step. We compare this method to three baselines: (1) directly asking the LLM to generate tests, (2) repeatedly querying the LLM when tests fail, and (3) search-based test generation with Pynguin. Our experiments evaluate these methods based on several factors, including mutation score, code coverage, success rate, and the ability to identify equivalent mutants. The results demonstrate that LLMs, although requiring higher computation cost, consistently outperform Pynguin in generating tests with better fault detection and coverage. Importantly, we observe that the iterative refinement of test cases is important for achieving high-quality test suites.
title Mutation Testing via Iterative Large Language Model-Driven Scientific Debugging
topic Software Engineering
url https://arxiv.org/abs/2503.08182