Submitted:
12 October 2023
Posted:
16 October 2023
You are already at the latest version
Abstract
Keywords:
1. Introduction
2. Background
2.1. Test Code Refactoring
2.2. Mutation Testing
3. Related Work
4. MeteoR: An Integrated Tool Proposal for Test Code Refactoring
4.1. The MeteoR Workflow
4.2. MeteoR Software Components
5. Preliminary evaluation of the proposed tool
5.1. Methodology
5.2. Positive Test Procedure Execution
5.2.1. Assessing the bad smells before test code refactoring
5.2.2. First run of pre-refactoring mutation testing
5.2.3. Test code refactoring
5.2.4. Mutation testing run
5.3. Negative Test Procedure Execution
5.3.1. Test Code Refactoring
5.3.2. Mutation Testing Run
5.4. Mutation Data Compilation and Comparison
6. Result Analysis and Discussions
- Ensure to isolate the tests only for the relevant classes within the scope of the refactoring.
- Evaluate the possibility of improving the parallelism to accelerate the generation and treatment of mutants.
- Consider preventing the modification of productive classes while the test classes are refactored.
- Reuse as much as possible the previously generated mutants; it is believed that there will be a decrease in the computational cost of changing the code for generating mutations and compiling the project, that is, evaluating how these mutants can be maintained so that a complete build is not necessary for each new execution of the mutation testing.
7. Conclusion
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
Abbreviations
| IDE | Integrated Development Environment |
| SUT | System Under Testing |
| TCT | Test-to-Code Traceability |
| UML | Unifed Modeling Language |
References
- Parsai, A.; Murgia, A.; Soetens, Q.D.; Demeyer, S. Mutation Testing as a Safety Net for Test Code Refactoring. In Proceedings of the Scientific Workshop Proceedings of the XP2015, New York, NY, USA, 2015; XP ’15 workshops. [CrossRef]
- Meszaros, G. xUnit Test Patterns: Refactoring Test Code; Pearson Education, 2007.
- Bladel, B.v.; Demeyer, S. Test Behaviour Detection as a Test Refactoring Safety. In Proceedings of the Proceedings of the 2nd International Workshop on Refactoring, New York, NY, USA, 2018; IWoR 2018, p. 22–25. [CrossRef]
- Offutt, A.J.; Untch, R.H. Mutation 2000: Uniting the Orthogonal; Springer US: Boston, MA, 2001; pp. 34–44. [CrossRef]
- Guerra, E.M.; Fernandes, C.T. Refactoring Test Code Safely. In Proceedings of the International Conference on Software Engineering Advances (ICSEA 2007), 2007, pp. 44–44. [CrossRef]
- Van Deursen, A.; Moonen, L.; Van Den Bergh, A.; Kok, G. Refactoring test code. In Proceedings of the Proc. Int’l Conf. eXtreme Programming and Flexible Processes in Software Engineering (XP); Marchesi, M., Ed., 2001.
- Wohlin, C. Guidelines for Snowballing in Systematic Literature Studies and a Replication in Software Engineering. In Proceedings of the Proceedings of the 18th International Conference on Evaluation and Assessment in Software Engineering, New York, NY, USA, 2014; EASE ’14. [CrossRef]
- Pizzini, A. Behavior-based test smells refactoring : Toward an automatic approach to refactoring Eager Test and Lazy Test smells. In Proceedings of the 2022 IEEE/ACM 44th International Conference on Software Engineering: Companion Proceedings (ICSE-Companion), 2022, pp. 261–263. [CrossRef]
- AlOmar, E.A.; Mkaouer, M.W.; Newman, C.; Ouni, A. On Preserving the Behavior in Software Refactoring: A Systematic Mapping Study. Inf. Softw. Technol. 2021, 140. [CrossRef]
- Soares, G. Making program refactoring safer. In Proceedings of the 2010 ACM/IEEE 32nd International Conference on Software Engineering, 2010, Vol. 2, pp. 521–522. [CrossRef]
- Aljawabrah, N.; Gergely, T.; Misra, S.; Fernandez-Sanz, L. Automated Recovery and Visualization of Test-to-Code Traceability (TCT) Links: An Evaluation. IEEE Access 2021, 9, 40111–40123. [CrossRef]
- van Bladel, B.; Demeyer, S. Test Refactoring: a Research Agenda. In Proceedings of the Proceedings SATToSE, 2017.
- Peruma, A.; Almalki, K.; Newman, C.D.; Mkaouer, M.W.; Ouni, A.; Palomba, F. TsDetect: An Open Source Test Smells Detection Tool. In Proceedings of the Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, New York, NY, USA, 2020; ESEC/FSE 2020, p. 1650–1654. [CrossRef]
- Marinke, R.; Guerra, E.M.; Fagundes Silveira, F.; Azevedo, R.M.; Nascimento, W.; de Almeida, R.S.; Rodrigues Demboscki, B.; da Silva, T.S. Towards an Extensible Architecture for Refactoring Test Code. In Proceedings of the Computational Science and Its Applications – ICCSA 2019; Misra, S.; Gervasi, O.; Murgante, B.; Stankova, E.; Korkhov, V.; Torre, C.; Rocha, A.M.A.; Taniar, D.; Apduhan, B.O.; Tarantino, E., Eds., Cham, 2019; pp. 456–471.
- Papadakis, M.; Kintis, M.; Zhang, J.; Jia, Y.; Traon, Y.L.; Harman, M. Chapter Six - Mutation Testing Advances: An Analysis and Survey; Elsevier, 2019; Vol. 112, Advances in Computers, pp. 275–378. [CrossRef]
- Singh, D.; Suri, B. Mutation testing tools- An empirical study. In Proceedings of the Third International Conference on Computational Intelligence and Information Technology (CIIT 2013), 2013, pp. 230–239. [CrossRef]
- Monteiro, R.; Durelli, V.H.S.; Eler, M.; Endo, A. An Empirical Analysis of Two Mutation Testing Tools for Java. In Proceedings of the Proceedings of the 7th Brazilian Symposium on Systematic and Automated Software Testing, New York, NY, USA, 2022; SAST ’22, p. 49–58. [CrossRef]
- Offutt, J. A mutation carol: Past, present and future. Information and Software Technology 2011, 53, 1098–1107. Special Section on Mutation Testing, . [CrossRef]
- Zhu, Q.; Zaidman, A.; Panichella, A. How to kill them all: An exploratory study on the impact of code observability on mutation testing. Journal of Systems and Software 2021, 173, 110864. [CrossRef]
- Ojdanic, M.; Soremekun, E.; Degiovanni, R.; Papadakis, M.; Le Traon, Y. Mutation Testing in Evolving Systems: Studying the Relevance of Mutants to Code Evolution. ACM Trans. Softw. Eng. Methodol. 2022. [CrossRef]
- Soares, E.; Ribeiro, M.; Amaral, G.; Gheyi, R.; Fernandes, L.; Garcia, A.; Fonseca, B.; Santos, A. Refactoring Test Smells: A Perspective from Open-Source Developers. In Proceedings of the Proceedings of the 5th Brazilian Symposium on Systematic and Automated Software Testing, New York, NY, USA, 2020; SAST 20, p. 50–59. [CrossRef]
| 1 | |
| 2 | |
| 3 | The term “test smells” was coined by Van Deursen et al. [6] as a name for symptoms in the test code that possibly indicate a deeper problem. |
| 4 | |
| 5 | AlOmar et al. [9] underline the importance of integrating this kind of tool with control version systems such as Git or Subversion. |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 |







| # | Stage | Role |
| S1 | Source code extraction and commit | Connectivity with the GIT tool. |
| S2 | Identification of test smells | Integration with any pre-existing tool in order to provide quick verification of test codes that need improvement. |
| S3 | Refactoring | Perform the refactoring in an assisted way, trying to solve the test code quality gaps with automated fix suggestions. |
| S4a | Execution of mutation testing | Use of a tool to generate test mutants and run mutation testing to assess the quality of project tests. Its first run will serve as a test baseline. |
| S4b | Reexecution of the mutation testing | Re-run the mutation testing scenarios under the refactored test code and compare the new results with the baseline result. |
| S5 | IDE Plugin Integration | Orchestrate test mutation runs, collecting data, performing analysis, and generating results reports. |
| S6 | Assessment | Have mutants been modified? Comparing results will provide those answers. If there was no change in the state of the mutants, then the refactoring was done successfully. |
| S7 | Traceability and Classification | Catalog and identification of test mutants (killed and surviving). Improve traceability in the refactoring cycles. |
| S8 | Analytics | Evaluate data and generate views to monitor the evolution of test mutants throughout code refactorings. |
| S9 | Mutant Validation Predictive Models | Application of Machine Learning and AI tools to obtain insights, refinement, prediction, and selection of test mutants. |
| Legend: S# = Stage in Figure 3 | ||
| Component | Description |
|---|---|
| IDE Eclipse Plugin | An IDE plugin implementation provides a familiar environment for developers to perform refactoring and analysis tasks within a single tool. This approach will allow for a streamlined development experience, improving productivity and reducing the possibility of errors. |
| Mutation Testing Execution Agent | Component that calls the PITest tool to generate and run mutant testing. |
| Comparison Report Generator | The data should be compared pre- and post-refactoring from the test mutants and a report generated indicates whether there was any change in the test behaviors. This report not only include a one-to-one comparison of mutations, but it will also evaluate the mutation scores. |
| Results Storage Management | Local storage to maintain the results and other artifacts. |
| Relative test file path | Number of methods | Assertion roulette |
| CSVRecordTest.java | 31 | 13 |
| CSVDuplicateHeaderTest.java | 4 | 2 |
| IOUtilsTest.java | 1 | 0 |
| Class | Line Coverage | Mutation Coverage | Test Strength |
| (mutation score) | (mutation score) | ||
| CSVRecord | 49/49 | 47/48 | 47/48 |
| () | () |
| Class | Line Coverage | Mutation Coverage | Test Strength |
| (mutation score) | (mutation score) | ||
| CSVRecord | 49/49 | 47/48 | 47/48 |
| () | () |
| Class | Line Coverage | Mutation Coverage | Test Strength |
| (mutation score) | (mutation score) | ||
| CSVRecord | 49/49 | 46/48 | 46/48 |
| () | () |


Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).