计算机应用 ›› 2020, Vol. 40 ›› Issue (1): 212-217.DOI: 10.11772/j.issn.1001-9081.2019060969

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

基于页面对象的Web应用测试用例生成方法

王曙燕, 郑佳妮, 孙家泽   

  1. 西安邮电大学 计算机学院, 西安 710121
  • 收稿日期:2019-06-10 修回日期:2019-07-21 出版日期:2020-01-10 发布日期:2019-09-27
  • 作者简介:王曙燕(1964-),女,陕西西安人,教授,博士,CCF会员,主要研究方向:软件测试、数据挖掘、智能信息处理;郑佳妮(1995-),女,陕西汉中人,硕士研究生,CCF会员,主要研究方向:可信软件、Web应用测试;孙家泽(1980-),男,陕西西安人,教授,博士,CCF会员,主要研究方向:软件测试、数据挖掘、智能信息处理。
  • 基金资助:
    陕西省科技厅工业科技攻关项目(2018GY-014,2017GY-092);西安市科技计划项目(GXYD17.10);西安邮电大学研究生创新基金重点项目(CXJJLI2018016)。

Test case generation method for Web applications based on page object

WANG Shuyan, ZHENG Jiani, SUN Jiaze   

  1. School of Computer Science and Technology, Xi'an University of Posts and Telecommunications, Xi'an Shaanxi 710121, China
  • Received:2019-06-10 Revised:2019-07-21 Online:2020-01-10 Published:2019-09-27
  • Contact: 王曙燕
  • Supported by:
    This work is partially supported by the Industrial Science and Technology Research Project of Shaanxi Provincial Science and Technology Department (2018GY-014, 2017GY-092), the Science and Technology Project of Xi'an City (GXYD17.10), the Graduate Innovation Fund Key Project in Xi'an University of Posts and Telecommunications (CXJJLI2018016).

摘要: 针对Web应用测试用例生成过程中导航图规模过大以及存在冗余测试路径的问题,提出了一种基于Selenium页面对象设计模式和图遍历算法的Web应用测试用例生成方法。首先,通过将原始页面对象进行分类,以导航页面对象类为节点、导航方法为迁移边构建页面对象导航图;其次,结合图的最短路径算法提出了一种页面对象图算法(POGA)来遍历导航图以生成测试路径集;最后,提取测试路径,利用Faker生成模拟数据,进一步生成可以直接执行的测试用例。实验结果表明:与爬取Web应用生成导航图的规模相比,该方法约简率约为89%;与基于状态迁移生成Web应用测试用例的方法相比,该方法减小了冗余和不可行路径的数量,并进一步提高了页面对象的复用率和测试用例的可维护性。

关键词: 页面对象, Web应用, 测试用例, 测试路径, 导航图

Abstract: To reduce the navigation graph size and redundant test paths in the generation process of Web application test cases, a Web application test case generation method based on Selenium page object design pattern and graph traversal algorithm was proposed. Firstly, by classifying the original page objects, the page object navigation graph with navigation page object class as the node and the navigation method as the migration edge was created. Secondly, with the shortest-path algorithm of graph, a Page Object Graph Algorithm (POGA) was proposed to realize the navigation graph traversal in order to generate test path set. Finally, the test paths were extracted and Faker was used to generate the simulated data, and the test cases that can be directly executed were produced. The experimental results show that, the proposed method has the reduction rate of about 89% compared with the navigation graph size generated by crawling Web applications, reduces the number of redundant and infeasible paths in comparison with the state migration method for generating Web application test cases, and further improves the reuse rate of page objects and the maintainability of test cases.

Key words: page object, Web application, test case, test path, navigation graph

中图分类号: