计算机应用 ›› 2017, Vol. 37 ›› Issue (4): 1143-1148.DOI: 10.11772/j.issn.1001-9081.2017.04.1143

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

针对JavaScript浏览器兼容性的变异测试方法

程勇, 秦丹, 杨光   

  1. 北京化工大学 信息科学与技术学院, 北京 100029
  • 收稿日期:2016-08-17 修回日期:2016-09-23 出版日期:2017-04-10 发布日期:2017-04-19
  • 通讯作者: 程勇
  • 作者简介:程勇(1976-),男,湖南华容人,讲师,博士,CCF会员,主要研究方向:大规模机器学习、数据挖掘;秦丹(1991-),女,山东临沂人,硕士,主要研究方向:软件测试;杨光(1984-),男,广西北海人,硕士,主要研究方向:人工智能、自然语言理解。
  • 基金资助:
    国家自然科学基金资助项目(61672085)。

Mutation test method for browser compatibility of JavaScript

CHENG Yong, QIN Dan, YANG Guang   

  1. College of Information Science and Technology, Beijing University of Chemical Technology, Beijing 100029, China
  • Received:2016-08-17 Revised:2016-09-23 Online:2017-04-10 Published:2017-04-19
  • Supported by:
    This work is partially supported by the National Natural Science Foundation of China (61672085).

摘要: 针对JavaScript浏览器兼容性问题缺乏有效的测试方法的问题,基于变异测试技术,对Web应用程序中的JavaScript语言在主流浏览器中的兼容性进行了分析,设计了18个针对浏览器兼容性错误的变异算子并开发了自动化的测试工具Compatibility Mutator。该程序使用抽象语法树(AST)分析JavaScript语法,使用Selenium WebDriver自动调用多个浏览器核心并行执行变异测试。通过对7个广泛使用的JavaScript框架的实验,验证了此方法对每一个框架都能够生成一定数量的变异体,其中对jQuery和YUI框架的变异测试的变异得分分别为43.06%和7.69%,表明了所设计的变异算子能够触发浏览器兼容性方面的错误,并且能够评估测试用例集的完备性。

关键词: 变异测试, JavaScript, 兼容性, 变异算子, 测试工具

Abstract: Since the research on testing technology for JavaScript browser compatibility problems is insufficient, based on mutation testing method and the analysis on the compatibility of JavaScript in Web applications in major browsers, eighteen mutation operators was designed, and an automated testing tool named Compatibility Mutator was implemented. Compatibility Mutator analyze JavaScript syntax with Abstract Syntax Tree (AST), calls various browsers with Selenium WebDriver to run mutation testing automatically and concurrently. The experiments on 7 widely-used JavaScript frameworks showed that the proposed mutation operators could generate a certain amount of mutants, the mutation scores got from mutation testing on jQuery and YUI were 43.06% and 7.69% respectively. Experimental results prove that the proposed operators can trigger the compatibility issues effectively, and evaluate the completeness of test suite effectively in finding the browser compatibility issues.

Key words: mutation testing, JavaScript, compatibility, mutation operator, testing tool

中图分类号: