{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,11,21]],"date-time":"2026-11-21T19:42:08Z","timestamp":1795290128015,"version":"4.10.3"},"reference-count":41,"publisher":"Association for Computing Machinery (ACM)","issue":"FSE","license":[{"start":{"date-parts":[[2025,6,19]],"date-time":"2025-06-19T00:00:00Z","timestamp":1750291200000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/legalcode"}],"content-domain":{"domain":[],"crossmark-restriction":false},"short-container-title":["Proc. ACM Softw. Eng."],"published-print":{"date-parts":[[2025,6,19]]},"abstract":"<jats:p>\n                    Test smells arise from poor design practices and insufficient domain knowledge, which can lower the quality of test code and make it harder to maintain and update. Manually refactoring of test smells is time-consuming and error-prone, highlighting the necessity for automated approaches. Current rule-based refactoring methods often struggle in scenarios not covered by predefined rules and lack the flexibility needed to handle diverse cases effectively. In this paper, we propose a novel approach called\n                    <jats:sc>UTRefactor<\/jats:sc>\n                    , a context-enhanced, LLMbased framework for automatic test refactoring in Java projects.\n                    <jats:sc>UTRefactor<\/jats:sc>\n                    extracts relevant context from test code and leverages an external knowledge base that includes test smell definitions, descriptions, and DSLbased refactoring rules. By simulating the manual refactoring process through a chain-of-thought approach,\n                    <jats:sc>UTRefactor<\/jats:sc>\n                    guides the LLM to eliminate test smells in a step-by-step process, ensuring both accuracy and consistency throughout the refactoring. Additionally, we implement a checkpoint mechanism to facilitate comprehensive refactoring, particularly when multiple smells are present. We evaluate\n                    <jats:sc>UTRefactor<\/jats:sc>\n                    on 879 tests from six open-source Java projects, reducing the number of test smells from 2,375 to 265, achieving an 89% reduction.\n                    <jats:sc>UTRefactor<\/jats:sc>\n                    outperforms direct LLM-based refactoring methods by 61.82% in smell elimination and significantly surpasses the performance of a rule-based test smell refactoring tool. Our results demonstrate the effectiveness of\n                    <jats:sc>UTRefactor<\/jats:sc>\n                    in enhancing test code quality while minimizing manual involvement.\n                  <\/jats:p>","DOI":"10.1145\/3715750","type":"journal-article","created":{"date-parts":[[2025,6,19]],"date-time":"2025-06-19T11:15:34Z","timestamp":1750331734000},"page":"713-733","source":"Crossref","is-referenced-by-count":21,"title":["Automated Unit Test Refactoring"],"prefix":"10.1145","volume":"2","author":[{"ORCID":"https:\/\/orcid.org\/0009-0000-2554-2381","authenticated-orcid":false,"given":"Yi","family":"Gao","sequence":"first","affiliation":[{"name":"Zhejiang University, The State Key Laboratory of Blockchain and Data Security, Hangzhou, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-0093-3292","authenticated-orcid":false,"given":"Xing","family":"Hu","sequence":"additional","affiliation":[{"name":"Zhejiang University, The State Key Laboratory of Blockchain and Data Security, Hangzhou, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-4111-4189","authenticated-orcid":false,"given":"Xiaohu","family":"Yang","sequence":"additional","affiliation":[{"name":"Zhejiang University, The State Key Laboratory of Blockchain and Data Security, Hangzhou, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-6302-3256","authenticated-orcid":false,"given":"Xin","family":"Xia","sequence":"additional","affiliation":[{"name":"Zhejiang University, The State Key Laboratory of Blockchain and Data Security, Hangzhou, China"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2025,6,19]]},"reference":[{"key":"e_1_3_1_2_2","unstructured":"[n.d.]. Apache. https:\/\/www.apache.org\/."},{"key":"e_1_3_1_3_2","unstructured":"[n.d.]. ChatGPT. https:\/\/chat.openai.com\/."},{"key":"e_1_3_1_4_2","unstructured":"[n.d.]. Commons-cli. https:\/\/github.com\/apache\/commons-cli."},{"key":"e_1_3_1_5_2","unstructured":"[n. d.]. Commons-compress. https:\/\/github.com\/apache\/commons-compress."},{"key":"e_1_3_1_6_2","unstructured":"[n. d.]. Commons-math-legacy. https:\/\/github.com\/apache\/commons-math\/tree\/master\/commons-math-legacy."},{"key":"e_1_3_1_7_2","unstructured":"[n.d.]. CoT. https:\/\/arxiv.org\/abs\/2201.11903."},{"key":"e_1_3_1_8_2","unstructured":"[n.d.]. GPT-4o. https:\/\/openai.com\/index\/hello-gpt-4o\/."},{"key":"e_1_3_1_9_2","unstructured":"[n.d.]. Gson. https:\/\/github.com\/google\/gson."},{"key":"e_1_3_1_10_2","unstructured":"[n. d.]. Jacoco. https:\/\/www.jacoco.org\/jacoco\/trunk\/index.html."},{"key":"e_1_3_1_11_2","unstructured":"[n. d.]. Jfreechart. https:\/\/github.com\/jfree\/jfreechart."},{"key":"e_1_3_1_12_2","unstructured":"[n. d.]. Jsoup. https:\/\/github.com\/jhy\/jsoup."},{"key":"e_1_3_1_13_2","unstructured":"[n. d.]. Llama3-70B. https:\/\/huggingface.co\/meta-llama\/Meta-Llama-3-70B."},{"key":"e_1_3_1_14_2","unstructured":"[n. d.]. Rascal. https:\/\/www.rascal-mpl.org\/."},{"key":"e_1_3_1_15_2","unstructured":"[n. d.]. SRP. https:\/\/en.wikipedia.org\/wiki\/Single-responsibility_principle."},{"key":"e_1_3_1_16_2","unstructured":"[n. d.]. tsDetect. https:\/\/github.com\/TestSmells\/TSDetect."},{"key":"e_1_3_1_17_2","unstructured":"[n. d.]. UTRefactor. https:\/\/github.com\/testmigrator\/testsmellrefactoring."},{"key":"e_1_3_1_18_2","doi-asserted-by":"publisher","DOI":"10.1007\/S10664-022-10278-4"},{"key":"e_1_3_1_19_2","doi-asserted-by":"publisher","unstructured":"Wajdi Aljedaani Anthony Peruma Ahmed Aljohani Mazen Alotaibi Mohamed Wiem Mkaouer Ali Ouni Christian D Newman Abdullatif Ghallab and Stephanie Ludi. 2021. Test smell detection tools: A systematic mapping study. In Proceedings of the 25th International Conference on Evaluation and Assessment in Software Engineering. 170\u2013180. https:\/\/doi.org\/10.1145\/3463274.3463335 10.1145\/3463274.3463335","DOI":"10.1145\/3463274.3463335"},{"key":"e_1_3_1_20_2","doi-asserted-by":"publisher","unstructured":"Alexandru Bodea. 2022. Pytest-Smell: a smell detection tool for Python unit tests. In Proceedings of the 31st ACM SIGSOFT International Symposium on Software Testing and Analysis. 793\u2013796. https:\/\/doi.org\/10.1145\/3533767.3543290 10.1145\/3533767.3543290","DOI":"10.1145\/3533767.3543290"},{"key":"e_1_3_1_21_2","doi-asserted-by":"publisher","DOI":"10.5753\/JSERD.2023.3195"},{"key":"e_1_3_1_22_2","doi-asserted-by":"publisher","unstructured":"Humberto Damasceno Carla Bezerra Emanuel Coutinho and Ivan Machado. 2022. Analyzing test smells refactoring from a developers perspective. In Proceedings of the XXI Brazilian Symposium on Software Quality. 1\u201310. https:\/\/doi.org\/10.1145\/3571473.3571487 10.1145\/3571473.3571487","DOI":"10.1145\/3571473.3571487"},{"key":"e_1_3_1_23_2","first-page":"1","volume-title":"2012 Spring congress on engineering and technology","author":"Danphitsanuphan Phongphan","year":"2012","unstructured":"Phongphan Danphitsanuphan and Thanitta Suwantada. 2012. Code smell detecting tool and code smell-structure bug relationship. In 2012 Spring congress on engineering and technology. IEEE, 1\u20135."},{"key":"e_1_3_1_24_2","doi-asserted-by":"crossref","unstructured":"Estevan Alexander de Paula and Rodrigo Bonif\u00e1cio. 2022. TestAXE: Automatically Refactoring Test Smells Using JUnit 5 Features. In Congresso Brasileiro de Software: Teoria e Pr\u00e1tica (CBSoft). SBC 89\u201398.","DOI":"10.5753\/cbsoft_estendido.2022.227655"},{"key":"e_1_3_1_25_2","doi-asserted-by":"publisher","unstructured":"Xueying Du Geng Zheng Kaixin Wang Jiayi Feng Wentai Deng Mingwei Liu Bihuan Chen Xin Peng Tao Ma and Yiling Lou. 2024. Vul-RAG: Enhancing LLM-based Vulnerability Detection via Knowledge-level RAG. arXiv preprint arXiv:2406.11147 (2024). https:\/\/doi.org\/10.48550\/ARXIV.2406.11147 10.48550\/ARXIV.2406.11147","DOI":"10.48550\/ARXIV.2406.11147"},{"key":"e_1_3_1_26_2","doi-asserted-by":"publisher","unstructured":"Daniel Fernandes Ivan Machado and Rita Maciel. 2022. TEMPY: Test smell detector for Python. In Proceedings of the XXXVI Brazilian Symposium on Software Engineering. 214\u2013219. https:\/\/doi.org\/10.1145\/3555228.3555280 10.1145\/3555228.3555280","DOI":"10.1145\/3555228.3555280"},{"key":"e_1_3_1_27_2","doi-asserted-by":"publisher","DOI":"10.1109\/ICSME52107.2021.00022"},{"key":"e_1_3_1_28_2","doi-asserted-by":"publisher","DOI":"10.1007\/S11219-024-09663-7"},{"key":"e_1_3_1_29_2","doi-asserted-by":"publisher","DOI":"10.1145\/1118890.1118892"},{"key":"e_1_3_1_30_2","doi-asserted-by":"publisher","unstructured":"Nicholas Alexandre Nagy and Rabe Abdalkareem. 2022. On the co-occurrence of refactoring of test and source code. In Proceedings of the 19th International Conference on Mining Software Repositories. 122\u2013126. https:\/\/doi.org\/10.1145\/3524842.3528529 10.1145\/3524842.3528529","DOI":"10.1145\/3524842.3528529"},{"key":"e_1_3_1_31_2","doi-asserted-by":"publisher","DOI":"10.1109\/ICSME.2018.00040"},{"key":"e_1_3_1_32_2","doi-asserted-by":"crossref","unstructured":"Anthony Peruma Khalid Almalki Christian D Newman Mohamed Wiem Mkaouer Ali Ouni and Fabio Palomba. 2020. Tsdetect: An open source test smells detection tool. In Proceedings of the 28th ACM joint meeting on european software engineering conference and symposium on the foundations of software engineering. 1650\u20131654.","DOI":"10.1145\/3368089.3417921"},{"key":"e_1_3_1_33_2","doi-asserted-by":"publisher","unstructured":"Adriano Pizzini. 2022. Behavior-based test smells refactoring: Toward an automatic approach to refactoring eager test and lazy test smells. In Proceedings of the ACM\/IEEE 44th International Conference on Software Engineering: Companion Proceedings. 261\u2013263. https:\/\/doi.org\/10.1145\/3510454.3517059 10.1145\/3510454.3517059","DOI":"10.1145\/3510454.3517059"},{"key":"e_1_3_1_34_2","doi-asserted-by":"crossref","unstructured":"Adriano Pizzini Sheila Reinehr and Andreia Malucelli. 2023. Sentinel: A process for automatic removing of Test Smells. In Proceedings of the XXII Brazilian Symposium on Software Quality. 80\u201389.","DOI":"10.1145\/3629479.3630019"},{"key":"e_1_3_1_35_2","doi-asserted-by":"publisher","DOI":"10.48550\/ARXIV.2208.07574"},{"key":"e_1_3_1_36_2","doi-asserted-by":"publisher","DOI":"10.1016\/J.SCIC0.2023.103013"},{"key":"e_1_3_1_37_2","doi-asserted-by":"crossref","unstructured":"Elvys Soares M\u00e1rcio Ribeiro Guilherme Amaral Rohit Gheyi Leo Fernandes Alessandro Garcia Baldoino Fonseca and Andr\u00e9 Santos. 2020. Refactoring test smells: A perspective from open-source developers. In Proceedings of the 5th Brazilian Symposium on Systematic and Automated Software Testing. 50\u201359.","DOI":"10.1145\/3425174.3425212"},{"key":"e_1_3_1_38_2","doi-asserted-by":"publisher","DOI":"10.1109\/TSE.2022.3172654"},{"key":"e_1_3_1_39_2","doi-asserted-by":"publisher","unstructured":"T\u00e1ssio Virg\u00ednio Luana Martins Larissa Rocha Railana Santana Adriana Cruz Heitor Costa and Ivan Machado. 2020. Jnose: Java test smell detector. In Proceedings of the XXXIV Brazilian Symposium on Software Engineering. 564\u2013569. https:\/\/doi.org\/10.1145\/3422392.3422499 10.1145\/3422392.3422499","DOI":"10.1145\/3422392.3422499"},{"key":"e_1_3_1_40_2","doi-asserted-by":"publisher","DOI":"10.1109\/ASE51524.2021.9678615"},{"key":"e_1_3_1_41_2","doi-asserted-by":"publisher","DOI":"10.1145\/3631973"},{"key":"e_1_3_1_42_2","doi-asserted-by":"publisher","DOI":"10.1145\/3660783"}],"container-title":["Proceedings of the ACM on Software Engineering"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3715750","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,8,23]],"date-time":"2026-08-23T11:01:00Z","timestamp":1787482860000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3715750"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2025,6,19]]},"references-count":41,"journal-issue":{"issue":"FSE","published-print":{"date-parts":[[2025,6,19]]}},"alternative-id":["10.1145\/3715750"],"URL":"https:\/\/doi.org\/10.1145\/3715750","relation":{},"ISSN":["2994-970X"],"issn-type":[{"value":"2994-970X","type":"electronic"}],"subject":[],"published":{"date-parts":[[2025,6,19]]}}}