TY - GEN
T1 - Migrating Unit Tests Across Java Applications
AU - Jha, Ajay Kumar
AU - Nadi, Sarah
N1 - Publisher Copyright:
© 2024 IEEE.
PY - 2024
Y1 - 2024
N2 - Writing effective unit tests is often tedious, difficult, and time-consuming. Test recommendation techniques facilitate this process by recommending existing manually written tests from other similar systems for developers to reuse. However, developers still have to put non-Trivial effort into modifying the recommended tests. For example, they have to understand vari-ous code elements in the recommended tests to accurately replace them with semantically similar code elements from the target system. In this paper, we propose JTESTMIGRATOR, a technique to automatically migrate unit tests between semantically similar methods across applications. Given a source and a target method with similar functionality across applications, where the source method has some unit tests, JTESTMIGRATOR migrates unit tests by transforming the test code. JTESTMIGRATOR uses semantic similarity and type compatibility of code elements in the source and target systems to transform test code. We implement JTESTMIGRATOR to migrate JUnit tests and evaluate it on 104 tests for 42 methods across 5 popular libraries. JTESTMIGRATOR successfully migrates 76 (73%) of the tests for 32 (76%) of the methods across the 5 libraries. 10 (13%) of the successfully migrated tests increase the code coverage of 4 target methods.
AB - Writing effective unit tests is often tedious, difficult, and time-consuming. Test recommendation techniques facilitate this process by recommending existing manually written tests from other similar systems for developers to reuse. However, developers still have to put non-Trivial effort into modifying the recommended tests. For example, they have to understand vari-ous code elements in the recommended tests to accurately replace them with semantically similar code elements from the target system. In this paper, we propose JTESTMIGRATOR, a technique to automatically migrate unit tests between semantically similar methods across applications. Given a source and a target method with similar functionality across applications, where the source method has some unit tests, JTESTMIGRATOR migrates unit tests by transforming the test code. JTESTMIGRATOR uses semantic similarity and type compatibility of code elements in the source and target systems to transform test code. We implement JTESTMIGRATOR to migrate JUnit tests and evaluate it on 104 tests for 42 methods across 5 popular libraries. JTESTMIGRATOR successfully migrates 76 (73%) of the tests for 32 (76%) of the methods across the 5 libraries. 10 (13%) of the successfully migrated tests increase the code coverage of 4 target methods.
KW - code transformation
KW - test migration
KW - test reuse
KW - unit testing
UR - http://www.scopus.com/inward/record.url?scp=85215262486&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=85215262486&partnerID=8YFLogxK
U2 - 10.1109/SCAM63643.2024.00022
DO - 10.1109/SCAM63643.2024.00022
M3 - Conference contribution
AN - SCOPUS:85215262486
T3 - Proceedings - 2024 IEEE International Conference on Source Code Analysis and Manipulation, SCAM 2024
SP - 131
EP - 142
BT - Proceedings - 2024 IEEE International Conference on Source Code Analysis and Manipulation, SCAM 2024
PB - Institute of Electrical and Electronics Engineers Inc.
T2 - 24th IEEE International Conference on Source Code Analysis and Manipulation, SCAM 2024
Y2 - 7 October 2024 through 8 October 2024
ER -