Migrating Unit Tests Across Java Applications

Ajay Kumar Jha, Sarah Nadi

Research output: Chapter in Book/Report/Conference proceedingConference contribution

Abstract

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.

Original languageEnglish (US)
Title of host publicationProceedings - 2024 IEEE International Conference on Source Code Analysis and Manipulation, SCAM 2024
PublisherInstitute of Electrical and Electronics Engineers Inc.
Pages131-142
Number of pages12
ISBN (Electronic)9798331528508
DOIs
StatePublished - 2024
Event24th IEEE International Conference on Source Code Analysis and Manipulation, SCAM 2024 - Flagstaff, United States
Duration: Oct 7 2024Oct 8 2024

Publication series

NameProceedings - 2024 IEEE International Conference on Source Code Analysis and Manipulation, SCAM 2024

Conference

Conference24th IEEE International Conference on Source Code Analysis and Manipulation, SCAM 2024
Country/TerritoryUnited States
CityFlagstaff
Period10/7/2410/8/24

Keywords

  • code transformation
  • test migration
  • test reuse
  • unit testing

ASJC Scopus subject areas

  • Software
  • Safety, Risk, Reliability and Quality
  • Modeling and Simulation

Fingerprint

Dive into the research topics of 'Migrating Unit Tests Across Java Applications'. Together they form a unique fingerprint.

Cite this