内容简介:EvoSuite是由Sheffield等大学联合开发的一种开源工具,用于自动生成测试用例集,生成的测试用例均符合Junit的标准,可直接在Junit中运行。得到了Google和Yourkit的支持。打开IDE,进入setting(mac版本是Preferences),选择plugins,点击Browse repositories,搜索EvoSuite Plugin,然后选择Install plugin。当前支持Maven3.1以上版本。 Maven工程可以通过引入EvoSuite的Maven插件来生成新的
EvoSuite简介
EvoSuite是由Sheffield等大学联合开发的一种开源工具,用于自动生成测试用例集,生成的测试用例均符合Junit的标准,可直接在Junit中运行。得到了Google和Yourkit的支持。
intelliJ IDEA插件
打开IDE,进入setting(mac版本是Preferences),选择plugins,点击Browse repositories,搜索EvoSuite Plugin,然后选择Install plugin。
Maven 插件引入
当前支持Maven3.1以上版本。 Maven工程可以通过引入EvoSuite的Maven插件来生成新的测试用例。使用Maven插件有如下好处:
-
1、可以和Jenkins结合,方便快速的运行EvoSuite
-
2、测试用例生成在pom.xml文件约定好的工程目录下
-
3、通过Maven的依赖引入EvoSuite,无需单独下载独立的jar文件。
插件的引入如下:
<pluginManagement><plugins> <plugin> <groupId>org.evosuite.plugins</groupId> <artifactId>evosuite-maven-plugin</artifactId> <version>${evosuiteVersion}</version> <executions><execution> <goals> <goal> prepare </goal> </goals> <phase> process-test-classes </phase> </execution></executions> </plugin></plugins></pluginManagement>复制代码
引入依赖:
<dependency> <groupId>org.evosuite</groupId> <artifactId>evosuite-standalone-runtime</artifactId> <version>${evosuiteVersion}</version> <scope>test</scope></dependency>复制代码
设定版本的变量(最新版可以在http://www.evosuite.org/downloads/查询):
<properties> <evosuiteVersion>1.0.6</evosuiteVersion></properties>复制代码
由于EvoSuite是生成的JUnit的文件,因此需要引入Junit的依赖。
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope></dependency>复制代码
EvoSuite的使用
EvoSuite的插件将会对对应的子模块的所有的类进行测试用例生成分析,再分析前需要保证对应代码是build过的。通过插件选取或者mvn compile evosuite:generate 开始分析。
默认情况下会在模块目录下生成.evosuite目录,目录里面是测试用例,如果想要修改那么可以通过如下插件进行配置
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>add-test-source</id> <phase>generate-test-sources</phase> <goals> <goal>add-test-source</goal> </goals> <configuration> <sources> <source>${customFolder}</source> </sources> </configuration> </execution> </executions></plugin>复制代码
特别提醒:如果上面的变量${customFolder}是.evosuite/evosuite-tests,那么不需要再次执行evosuite:export
详情参见官方文档:http://www.evosuite.org/documentation/
关注测者,关注测试
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Effective JavaScript
David Herman / Addison-Wesley Professional / 2012-12-6 / USD 39.99
"It's uncommon to have a programming language wonk who can speak in such comfortable and friendly language as David does. His walk through the syntax and semantics of JavaScript is both charming and h......一起来看看 《Effective JavaScript》 这本书的介绍吧!