针对存储过程混合了SQL语句以及流程控制等语句的特点,设计了一个变异工具SPMutation.定义了一个覆盖存储过程语法规则的变异算子集合,该算子集包含22个算子,能够对存储过程进行元素级、表达式级和语句级三种不同层次的变异操作.SPMutation通过配置变异算子集文件可以实现对存储过程新的语法规则的错误模拟,具有良好的可扩展性.实验表明:SPMutation能有效地生成变异体集合,生成的等价变异体数量少于总变异体数15%;通过变异测试过程完善测试用例集,可以使测试用例集的变异分数高于0.9,并趋近于1;对存储过程的变异测试可以在有限的时间内完成.
SPMutation is mutating tool designed for stored procedures,which is a mixture of SQL statements and process control statements.A mutation operator set was implemented in SPMutation and covered a wide spectrum of stored procedure.The set includes 22 operators,which can be attributed to three mutating levels,element level,expression level and statement level.SPMutation can achieve a good scalability in simulating errors for the new syntax regulations of stored procedures through configuring profiles,including a syntax file for stored procedure and a profile for mutation operator.Experiment results show that SPMutation can effectively generate mutants,in which equal mutants less than 15%total number of the mutants.The mutation score of test case suite can be more than 0.9and close to 1by being enhanced through the process of the mutation testing.SPMutation′s computation overhead is also acceptable,as all of the mutation testing of stored program can be done in a limited time.