Page 76 - 《软件学报》2025年第12期
P. 76
虞圣呈 等: 基于大模型语义匹配的跨平台移动应用测试脚本录制回放 5457
replay has become one of the prominent challenges in GUI testing. GUI test scripts must be migrated from traditional mobile platforms to
emerging mobile platforms to ensure the reliability of App quality and consistency in user experience across diverse platforms. However,
differences in underlying implementations across platforms have created substantial obstacles to the cross-platform migration of mobile
App test scripts. This challenge is particularly pronounced in the testing migration for emerging domestic mobile ecosystem platforms.
Cross-platform test script recording and replay is essential for maintaining consistency and a high-quality user experience across different
platforms and devices. Current state-of-the-art approaches only address the “one-to-one” test event matching situations. However, due to
inconsistencies in development practices across platforms, the replay of test events does not always map “one-to-one”; instead, “multiple-to-
multiple” mapping situations are common. This means that some test events need to be mapped to a different number of test events to
fulfill the same business logic. To address these issues and challenges, this study proposes a cross-platform mobile App test script
recording and replay method based on large language model semantic matching (LLMRR). The LLMRR method integrates image
matching, text matching, and large language model semantic matching technologies. During the recording phase, user operation information
is captured using image segmentation algorithms and saved as recorded test scripts. During the replay phase, corresponding widgets on the
replay App page are located using image matching and text matching modules to execute operations. When matching fails, the large
language model semantic matching module is invoked for semantic matching, ensuring efficient operation across different platforms. This
study presents the first exploration of testing for domestic HarmonyOS Apps, using 20 Apps and a total of 100 test scripts for migration
testing across iOS, Android, and HarmonyOS platforms. The effectiveness of the LLMRR method is compared with the current state-of-the-
art cross-platform test script recording and replay approaches, LIRAT and MAPIT. The results demonstrate that the LLMRR method
exhibits significant advantages in test script recording and replay.
Key words: GUI testing; HarmonyOS App testing; test script; record and replay; large language model (LLM)
随着移动应用的迅猛发展, 各类应用已深深融入人们的日常生活中, 并成为现代社会不可或缺的一部分. 面对
用户日益增长的需求和期望, 开发者也在不断追求技术创新和用户体验的提升, 以提供更高效、更便捷、更智能
的服务 [1] . 在这个背景下, 各种移动操作系统不断涌现, 国产系统如鸿蒙系统 (HarmonyOS) 逐渐崭露头角, 凭借其
独特的优势和创新的生态系统, 迅速成为市场中的重要一员, 受到越来越多用户和开发者的关注和青睐. 自 2019
年面世以来, 鸿蒙系统正成为继安卓 (Android) 和 iOS 之后的重要选择, 为用户和开发者提供更多元化的选择和更
高质量的服务. 随着其不断发展, 鸿蒙应用生态发展及其质量保障的重要性愈发凸显 [2] . 对于鸿蒙应用测试而言,
测试者需要考虑到各种可能的情况, 包括不同设备的屏幕尺寸、分辨率、性能差异等, 跨平台兼容性将成为鸿蒙
应用的基本要求, 开发者需要确保应用在不同设备型号和操作系统版本下都能正常运行, 提高应用的普适性和用
户体验. 此外, 还需要对应用在不同版本鸿蒙系统上的表现进行测试, 以确保应用的稳定性和兼容性. 这些工作不
仅需要耗费大量的时间和精力, 还需要具备专业的测试技能和经验.
虽然鸿蒙操作系统在初期与安卓系统具有一定的兼容性, 但随着其逐渐发展, 无论是系统特性还是应用特性,
均与安卓系统有着较大差异. 在内核架构方面, 鸿蒙系统基于分布式的微内核设计, 可以根据设备的功能需要进行
系统内核功能的搭配, 而安卓系统则基于 Linux 的宏内核架构, 运行在不同的设备上需要一整套内核功能; 因此鸿
蒙系统也具有更强的设备兼容性, 支持智能手机、智能穿戴设备、电脑、电视等多种智能家居设备, 形成一个无
缝的、统一的操作系统. 此外, 鸿蒙系统通过多重安全机制, 如隔离、加密通信和身份验证等, 确保了较高的安全
性能. 在其应用生态开发过程方面, 鸿蒙系统支持统一的开发框架和 API, 开发人员可以通过一次开发, 适配多个
设备, 减少开发工作量, 且可以通过方舟编译器将软件代码直接编译成机器语言, 提高了软件的运行效率, 安卓系
统则是在软件运行时边运行边编译, 运行效率相对较低. 因此, 对于其图形用户界面 (graphical user interface, GUI)
测试而言, 由于不同操作系统间底层支持的差异性, 现有的安卓和 iOS 版本应用测试脚本无法直接迁移到鸿蒙系
统上 [3] . 不同操作系统间底层支持差异使得应用在不同平台上的实现方式和交互流程有所不同, 对应 GUI 控件的
定位方式与页面结构也不尽一致, 导致测试脚本需要针对每个平台进行特定设计, 无法直接迁移. 现有的测试方法
通常是为特定平台量身定制的, 缺乏跨平台的通用性. 这意味着开发者需要为每个平台分别编写和维护测试脚本,
既耗时又易出错, 且需要测试开发者熟悉不同的测试框架. 然而, 尽管不同平台的应用实现方式和交互流程不同,
但其测试的核心目的往往是相同的, 即验证应用功能的正确性和用户体验的一致性. 然而, 由于底层架构的不同导
致动作序列存在显著差异, 确保所有平台上的测试结果一致性变得更加困难. 传统测试脚本录制回放仅解决了同

