Enhancing Mutation Testing through Grammar Fuzzing and Parse Tree-Driven Mutation Generation
Abstract
Mutation testing is a technique used to assess the effectiveness of software test suites. It works by deliberately introducing small, controlled changes, called mutations, into the code of the software under test (SUT). A robust and thorough test suite should be able to identify and detect these intentionally seeded errors. The key point is to ensure that the resulting mutant program can still be successfully loaded and executed, without causing compilation or runtime errors. The effectiveness of mutation testing directly depends on the nature and scope of the introduced mutations, as more advanced mutations and even targeted mutations can pose additional challenges to the test suite. This paper presents a novel approach leveraging parse trees and grammar fuzzing to create syntactically valid mutations. By generating a parse tree from the SUT’s source code, our method allows precise selection of target nodes and controls mutation granularity through Lexar and parser rules. A custom grammar fuzzer generates new code fragments, which are then semantically validated by a language-specific analyzer to ensure correctness. To address potential compilation issues, we propose selecting deeper parse tree nodes for mutations. Our approach enhances mutation testing precision, flexibility, and automation, ensuring valid and contextually appropriate code mutations. © 2024 IEEE.