计算机科学 ›› 2025, Vol. 52 ›› Issue (11): 330-338.doi: 10.11896/jsjkx.240900150

• 计算机软件 • 上一篇    下一篇

基于汤普森采样的自适应安卓程序测试方法

赵英男, 冷重阳, 韩启龙, 俞程   

  1. 哈尔滨工程大学计算机科学与技术学院 哈尔滨 150001
  • 收稿日期:2024-09-25 修回日期:2024-12-09 出版日期:2025-11-15 发布日期:2025-11-06
  • 通讯作者: 韩启龙(hanqilong@hrbeu.edu.cn)
  • 作者简介:(zhaoyingnan@hrbeu.edu.cn)
  • 基金资助:
    黑龙江省重点研发项目(KY10600230082)

Adaptive Android Program Test Method Based on Thompson Sampling

ZHAO Yingnan, LENG Chongyang, HAN Qilong, YU Cheng   

  1. College of Computer Science and Technology,Harbin Engineering University,Harbin 150001,China
  • Received:2024-09-25 Revised:2024-12-09 Online:2025-11-15 Published:2025-11-06
  • About author:ZHAO Yingnan,born in 1992,Ph.D,associate professor,master supervisor,is a member of CCF(No.P2652M).His main research interests include reinforcement learning and intelligent software engineering.
    HAN Qilong,born in 1974,Ph.D,professor,Ph.D supervisor.His main research interests include industrial data intelligence,big data analysis and mi-ning,data security and privacy computing,knowledge graph theory and applications,and industrial Internet.
  • Supported by:
    Key Research and Development Program of Heilongjiang Province(KY10600230082).

摘要: 近年来,安卓图形化界面测试方法的研究引起了学者的广泛关注。目前,大多数测试方法是基于强化学习开发的,然而,现有方法根据经验选择参数实现对应用程序的探索,无法根据界面变化情况自适应地改变参数设置。为此,提出了一种基于汤普森采样的自适应安卓测试方法,该方法将汤普森采样与Q-learning算法相结合,能够根据当前界面控件被探索的情况自适应地调整智能体下一步的探索动作,且能较好地平衡利用与探索的关系,实现更有效的测试。首先,对探索过程中界面的跳转这一事件进行Beta概率分布建模,得到一个概率分布矩阵,该矩阵与Q矩阵加权平均,可以兼顾事件的探索价值与利用价值。同时,对当前界面下的可操作事件的概率分布进行采样,最大采样值即为探索概率值,结合加权后的矩阵可以更全面地指导测试,以此实现对安卓应用界面的自适应探索。在13个安卓应用程序上进行了实验,通过与传统强化学习测试工具进行实验对比与分析,验证了所提方法的有效性。

关键词: 安卓GUI测试, 强化学习, Q-learning, 汤普森采样

Abstract: Recently,the research of Android graphical interface test method has attracted wide attention.At present,most test methods are developed based on reinforcement learning.However,the existing methods can explore the application by selecting parameters according to experience,and can not to change the parameter settings according to the interface changes adaptively.This paper proposes an adaptive Android testing method based on Thompson sampling,which combines Thompson sampling with the Q-learning algorithm,enabling the agent to adaptively determine the next exploration action based on the current state of the interface controls being examined so that to balance exploitation and exploration more effectively for superior testing outcomes.Firstly,events of the jump at the interface during exploration are modeled for the Beta probability distribution,then a probability distribution matrix is obtained,which is weighted-averaged with the Q-table.It can take into account both the exploration value and the exploition value of the events.At the same time,the probability distribution of operational events under the current interface is sampled,and the maximum sampling value is the exploration probability value,combined with the weighted matrix,it can guide the test more comprehensively,so as to realize the adaptive exploration of the Android application interface.Experiments executed on 13 Android applications confirm the efficacy of the proposed method through experimentalcomparison and analysis with conventional reinforcement learning testing tools.

Key words: Android GUI testing, Reinforcement learning, Q-learning, Thompson sampling

中图分类号: 

  • TP311
[1]LI Y,YANG Z,GUO Y,et al.Droidbot:a lightweight ui-guided test input generator for android[C]//2017 IEEE/ACM 39th International Conference on Software Engineering Companion.IEEE,2017:23-26.
[2]DONG Z,BÖHME M,COJOCARU L,et al.Time-travel testing of android apps[C]//Proceedings of the ACM/IEEE 42nd International Conference on Software Engineering.2020:481-492.
[3]ADAMO D,KHAN M K,KOPPULA S,et al.Reinforcement learning for android gui testing[C]//Proceedings of the 9th ACM SIGSOFT International Workshop on Automating TEST Case Design,Selection,and Evaluation.2018:2-8.
[4]KOROGLU Y,SEN A,MUSLU O,et al.Qbe:Qlearning-based exploration of android applications[C]//2018 IEEE 11th International Conference on Software Testing,Verification and Validation.IEEE,2018:105-115.
[5]VUONG T A T,TAKADA S.A reinforcement learning based approach to automated testing of android applications[C]//Proceedings of the 9th ACM SIGSOFT International Workshop on Automating TEST Case Design,Selection,and Evaluation.2018:31-37.
[6]MAOK,HARMAN M,JIA Y.Sapienz:Multi-objective automated testing for android applications[C]//Proceedings of the 25th International Symposium on Software Testing and Analysis.New York:ACM,2016:94-105.
[7]SU T,MENG G,CHEN Y,et al.Guided,stochastic model-basedGUI testing of Android apps[C]//Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering.New York:ACM,2017:245-256.
[8]LI Y,YANG Z,GUO Y,et al.DroidBot:A Lightweight UI-Guided Test Input Generator for Android[C]//2017 IEEE/ACM 39th International Conference on Software Engineering Companion.IEEE,2017:23-26.
[9]YASIN H N,HAMID S H A,YUSOF R J R.DroidbotX:Test Case Generation Tool for Android Applications Using Q-Lear-ning[J].Symmetry,2021,13(2):310.
[10]HANH,HAN W,RUIQI D,et al.Enhancing GUI Exploration Coverage of Android Apps with Deep Link-Integrated Monkey[J],ACM Transactions on Software Engineering and Methodo-logy,2024,33(6):163.
[11]LI Y,YANG Z,GUO Y,et al.Humanoid:A Deep Learning-Based Approach to Automated Black-box Android App Testing[C]//2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE).2019:1070-1073.
[12]PAN M,HUANG A,WANG G,et al.Reinforcement learningbased curiosity-driven testing of Android applications[C]//Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis.New York:ACM,2020:153-164.
[13]MINDOM P S N,NIKANJAM A,KHOMH F.A comparison of reinforcement learning frameworks for software testing tasks[J].Empirical Software Engineering,2023,28(5):article number 111.
[14]FUJIMOTO S,VAN HOOF H,MEGER D.Addressing Function Approximation Error in Actor-Critic Methods[J].arXiv:1802.09477,2018.
[15]GRUSLYS A,AZAR M G,BELLEMARE M G,et al.The Reactor:A Sample-Efficient Actor-Critic Architecture[J].arXiv:1704.04651,2017.
[16]GU S,LILLICRAP T,GHAHRAMANI Z,et al.Q-Prop:Sample-Efficient Policy Gradient with An Off-Policy Critic[J].ar-Xiv:1611.02247,2016.
[17]LILLICRAP T P,HUNT J J,PRITZEL A,et al.Continuouscontrol with deep reinforcement learning[J].arXiv:1509.02971,2015.
[18]HAARNOJA T,ZHOU A,ABBEEL P,et al.Soft Actor-Critic:Off-Policy Maximum Entropy Deep Reinforcement Learning with a Stochastic Actor[J].arXiv:1801.01290,2018.
[19]PAN M,HUANG A,WANG G,et al.Reinforcement learning based curiosity-driven testing of Android applications[C]//Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis.2020:153-164.
[20] MARIANI L,PEZZE M,RIGANELLI O,et al.AutoBlackTest:Automatic BlackBox Testing of Interactive Applications[C]//2012 IEEE Fifth International Conference on Software Testing,Verification and Validation.IEEE,2012:81-90.
[21]WATKINS C J C H,DAYAN P.Technical Note:Q-Learning[J].Machine Learning,1992,8(3/4):279-292.
[22]THOMPSON W R.On the likelihood that one unknown proba-bility exceeds another in view of the evidence of two samples[J].Biometrika,1933,25(3/4):285-294.
[23]FUJIMOTO S,VAN HOOF H,MEGER D.Addressing Func-tion Approximation Error in Actor-Critic Methods[J].arXiv:1802.09477,2018.
[24]MNIHV,KAVUKCUOGLU K,SILVER D,et al.Playing Atari with Deep Reinforcement Learning[J].arXiv:1312.5602,2013.
[25]CHOUDHARY S R,GORLA A,ORSO A.Automated Test Input Generation for Android:Are We There Yet? [C]//2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE).IEEE,2015:429-440.
[26]JaCoCo.Java code coverage library[DB/OL].https://www.jacoco.org/jacoco/.
[27]HUANG C Y,CHIU C H,LIN C H,et al.Code Coverage Meas-urement for Android Dynamic Analysis Tools[C]//2015 IEEE International Conference on Mobile Services.IEEE,2015:209-216.
[28]YANGS,HUANG S,HUI Z.Theoretical Analysis and Empirical Evaluation of Coverage Indictors for Closed Source APP Testing[J].IEEE Access,2019,7:162323-162332.
[29]ADAMO D,KHAN M K,KOPPULA S,et al.Reinforcement learning for Android GUI testing[C]//Proceedings of the 9th ACM SIGSOFT International Workshop on Automating TEST Case Design,Selection,and Evaluation.New York:ACM,2018:2-8.
[30]PILGUN A,GADYATSKAYA O,ZHAUNIAROVICH Y,et al.Fine-grained Code Coverage Measurement in Automated Black-box Android Testing[J].ACM Transactions on Software Engineering and Methodology,2020,29(4):1-35.
[31]SUT,MENG G,CHEN Y,et al.Guided,stochastic model-based GUI testing of Android apps[C]//Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering.New York:ACM,2017:245-256.
[32]KOROGLUY,SEN A,MUSLU O,et al.QBE:QLearning-Based Exploration of Android Applications[C]//2018 IEEE 11th International Conference on Software Testing,Verification and Validation.IEEE,2018.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!