Some test amplification tools extend a manually created test suite with additional test cases to increase the code coverage. The technique is effective, in the sense that it suggests strong and understandable test cases, generally adopted by software engineers. Unfortunately, the current state-of-the-art for test amplification heavily relies on program analysis techniques which benefit a lot from explicit type declarations present in statically typed languages. In dynamically typed languages, such type declarations are not available and as a consequence test amplification has yet to find its way to programming languages like Smalltalk, Python, Ruby and Javascript. We propose to exploit profiling information --readily obtainable by executing the associated test suite-- to infer the necessary type information creating special test inputs with corresponding assertions. We evaluated this approach on 52 selected test classes from 13 mature projects in the Pharo ecosystem containing approximately 400 test methods. We show the improvement in killing new mutants and mutation coverage at least in 28 out of 52 test classes (53%). Moreover, these generated tests are understandable by humans: 8 out of 11 pull-requests submitted were merged into the main code base (72%). These results are comparable to the state-of-the-art, hence we conclude that test amplification is feasible for dynamically typed languages.
翻译:一些测试放大工具扩展了人工制作的测试套件,增加了测试案例,以扩大代码覆盖范围。该技术是有效的,因为它表明软件工程师普遍采用强力和易懂的测试案例。不幸的是,目前测试放大的先进技术在很大程度上依赖于程序分析技术,这些技术在很大程度上得益于以静态类型语言提供的明确类型声明。在动态类型语言中,这种类型声明是不存在的,因此,测试扩增尚未找到方法来编程Smalltalk、Python、Ruby和Javascrip等语言。我们提议利用特征分析信息 -- -- 通过执行相关的测试套件可以容易地获得 -- -- 推断出必要的类型信息,通过相应的说法生成特殊测试投入。我们从Pharo生态系统中包含大约400种测试方法的13个成熟项目中对52个选定的测试类方法进行了评估。我们展示了在杀害新变异体和突变种覆盖范围方面至少28个测试类(53%)的改进情况。此外,这些产生的测试为人类所理解:提交的11项请求中有8项被合并成主要代码基(72 % ) 。这些测试的结果可以与动态类型相比较。