PSTR: A Test Case Reuse Method Based on Path Similarity

0Citations
Citations of this article
14Readers
Mendeley users who have this article in their library.

This article is free to access.

Abstract

Software testing plays a critical role throughout the software development lifecycle. In modern development practices, frequent and incremental updates to code are common, and each update typically necessitates the generation of new test cases. While the generation of test cases can be automated, the creation and adjustment of test oracles (expected outputs or behaviors) still require significant manual effort. This process is time-consuming and labor-intensive, particularly when code changes are minor, making repeated oracle creation inefficient. Meanwhile, test cases and their associated oracles from previous versions, having been refined and validated through multiple iterations, are highly reliable and valuable. However, due to the changes in execution paths introduced by code updates, it is unclear which old test cases remain applicable to the new version, leaving these valuable resources underutilized. Consequently, the ability to effectively identify and reuse applicable test cases and their oracles from previous versions is of paramount importance. Currently, research on test case reuse in unit testing is relatively sparse. Existing approaches often focus on software requirements and pay limited attention to code-level changes. Even methods that consider code changes fail to ensure precision in selecting test cases or maintain high coverage in the reused test set. To address these challenges, this paper proposes a novel approach, Path Similarity-based Test case Reuse (PSTR), tailored for the characteristics of unit testing. PSTR significantly enhances testing efficiency and reduces costs by accurately identifying reusable test cases through path similarity analysis. The proposed PSTR method consists of three core modules: static analysis, dynamic analysis, and reuse. First, static analysis is performed on both the old and new code versions to generate their respective sets of static paths. Next, the test cases from the old version are executed on its code, establishing a mapping between each test case and its covered execution paths. Finally, the path similarity algorithm compares paths between the old and new versions, allowing test cases associated with the most similar paths to be reused for the new version. For cases where direct reuse is not possible, the method provides clear guidance to assist testers in completing subsequent tasks more efficiently. For evaluation, a custom dataset derived from LeetCode problem solutions was used, and the PSTR method was compared with the classical ATR (All Test case Reuse) method. The results demonstrated the superiority of PSTR, achieving a precision rate of 95.64%, which is 14.87% higher than ATR. Additionally, while PSTR reused an average of 77.81% of test cases, it maintained a path coverage rate comparable to ATR, which reused 100% of test cases. Metrics such as F1-score, recall, and misuse rate further highlighted PSTR's advantages in accurate and effective test case reuse. Specifically, PSTR achieved comparable coverage with fewer reused test cases while significantly reducing the misuse rate. In summary, as an innovative test case reuse method, PSTR has demonstrated remarkable effectiveness and practicality. It reduces resource consumption, improves testing efficiency, and lowers testing costs while maintaining high coverage standards. The findings underscore PSTR's potential to make software testing more efficient and cost-effective.

Cite

CITATION STYLE

APA

Xu, X., Chen, S., Guo, Z., & Chen, X. (2025). PSTR: A Test Case Reuse Method Based on Path Similarity. IEEE Access, 13, 3175–3187. https://doi.org/10.1109/ACCESS.2024.3524596

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Save time finding and organizing research with Mendeley

Sign up for free