1.安装EvoSuite插件
以IDEA为例,在Plugins栏搜索EvoSuite后点击install,安装完成后重启IDEA

2.使用EvoSuite
选中文件右键选择Run EvoSuite


生成成功可以看到如下提示:

注意事项:
生成路径:src/test/java
使用junit4版本
然后在pom.xml文件添加如下依赖:
XML
<dependency>
<groupId>org.evosuite</groupId>
<artifactId>evosuite-standalone-runtime</artifactId>
<version>1.0.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>compile</scope>
</dependency>
选中用例文件,右键选择"Run * with Coverage"选项即可运行单元测试用例和查看单元测试覆盖率
