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