Mutation Operators for Code Annotations - Pinheiro, Pedro; Viana, José Carlos; Fernandes, Leonardo; Ribeiro, Márcio; Ferrari, Fabiano; Fonseca, Baldoino; Gheyi, Rohit (Anais do Simpósio Brasileiro de Testes de Software Sistemático e Automatizado (SAST); 2018: Anais do III Simpósio Brasileiro de Testes de Software Sistemático e Automatizado, 2018)
Mutation testing is a technique that injects artificial faults to check whether the existing test suite can detect them. To inject the faults, mutation testing tools rely on mutation operators, such as Arithmetic Operator Replacement, Relational Operator Replacement, Statement Deletion, and Overriding Method Rename. Most of the proposed mutation operators have focused on imperative language constructs and object-oriented constructs. However, many projects make use of meta-programming through code annotations, and mutation operators to simulate annotation-related faults are missing. To minimize this problem, in this paper we propose a set of mutation operators capable of simulating annotation-related faults. In particular, we define nine operators. To evaluate our operators, we mined Java projects that make heavy use of annotations to identify annotation-related faults. We analyzed 100 faults and categorized them as "misuse", when the developer does not know how to use the annotations in a proper way; and "wrong annotation parsing", when the developer wrongly parses annotation code (by using refection, for example). Our operators are able to simulate 95 out of the 100 mined faults. In particular, three operators are able to simulate up to 82% of the analyzed faults. As implications for practice, our operators can help developers to improve their test suite and the code responsible for parsing annotated code. Also, they can help developers to avoid annotation-related faults.