github地址:https://github.com/EvoSuite/evosuite
官网地址:http://www.evosuite.org
 
快速开始:
1.  junit 
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
 
2.添加 evosuite 插件
 <plugin>
<groupId>org.evosuite.plugins</groupId>
<artifactId>evosuite-maven-plugin</artifactId>
<version>1.0.6</version>
</plugin>
evosuite 的仓库
<pluginRepositories>
<pluginRepository>
<id>EvoSuite</id>
<name>EvoSuite Repository</name>
<url>http://www.evosuite.org/m2</url>
</pluginRepository>
</pluginRepositories> 
3.evosuite 的运行依赖
<dependency>
<groupId>org.evosuite</groupId>
<artifactId>evosuite-standalone-runtime</artifactId>
<version>1.0.6</version>
<scope>test</scope>
</dependency>

4.开始生成

mvn evosuite:generate
mvn compile -DmemoryInMB=2000 -Dcores=2 -Dcuts=com.xxx.xxx.api.service.impl.CurriculumServiceImpl-DtargetFolder=src/test/java/evosuite evosuite:generate evosuite:export
compile 表示编译。evosuite 是基于编译后的 .class 文件生成用例的,所以需要先编译。
-DmemoryInMB=2000 表示使用 2000MB 的内存
-Dcores=2 表示用2个 cpu 来并行加快生成速度
-Dcuts=com.xxx.xxx.api.service.impl.CurriculumServiceImpl 表示只针对 com.xxx.xxx.api.service.impl.CurriculumServiceImpl 这个类生成用例。多个用例可以用英文逗号分隔
-DtargetFolder=src/test/java/evosuite 表示生成的用例放到 src/test/java/evosuite
evosuite:generate 表示执行生成用例
evosuite:export 表示导出用例到 targetFolder 的值所在的目录中
 
Idea插件使用
http://www.evosuite.org/documentation/maven-plugin/
 
1.下载 evosuite-1.0.6 jar
2.idea安装evosuite插件
3.配置
2.evosuite -jacoco
注意:EvoSuite的bytecode instrumentation和类似Jacoco这类工具在bytecode instrumentation上有可能有冲突,导致最后的覆盖率统计都是0(修改separateClassLoader = true为false)
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<configuration>
<excludes>//排出不需要收集覆盖率的
<exclude>**/*ClazzSearchController.class</exclude>
<exclude>**/*Application.class</exclude>
<exclude>com/xxx/xxxx/api/config/**/*</exclude>
</excludes>
</configuration>
<executions>
<!-- <execution>-->
<!-- <id>prepare-agent</id>-->
<!-- <goals>-->
<!-- <goal>prepare-agent</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- <execution>-->
<!-- <id>report</id>-->
<!-- <phase>prepare-package</phase>-->
<!-- <goals>-->
<!-- <goal>report</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- <execution>-->
<!-- <id>post-unit-test</id>-->
<!-- <phase>test</phase>-->
<!-- <goals>-->
<!-- <goal>report</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <dataFile>target/jacoco.exec</dataFile>-->
<!-- <outputDirectory>target/jacoco-ut</outputDirectory>-->
<!-- </configuration>-->
<!-- </execution>-->
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>generate-code-coverage-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
 
2.执行命令
mvn jacoco:prepare-agent test jacoco:report
 

3.查看测试报告

单元测试自动生成工具evosuite的更多相关文章

  1. h5自动生成工具

    一.前言 写了很多h5之后,对于写手写html和css已经麻木的我决定动手写个工具自动生成h5结构和样式.其实这个想法由来已久,但总是觉得自己技术不够,所以一直没实行.直到某天我真的写够了,我决定动手 ...

  2. 代码自动生成工具MyGeneration之一(程序员必备工具)

    代码自动生成工具MyGeneration之一(程序员必备工具) 转 分类: C#2008-08-06 18:12 16064人阅读 评论(12) 收藏 举报 工具数据库相关数据库stringbrows ...

  3. Makefile自动生成工具-----autotools的使用(详细)

    相信每个学习Linux的人都知道Makefile,这是一个很有用的东西,但是编写它是比较复杂,今天介绍一个它的自动生成工具,autotools的使用.很多GNULinux的的软件都是用它生成Makef ...

  4. Asp.net mvc 5 CRUD代码自动生成工具- vs.net 2013 Saffolding功能扩展

    Asp.net mvc 5 CRUD代码自动生成工具 -Visual Studio.net2013 Saffolding功能扩展 上次做过一个<Asp.net webform scaffoldi ...

  5. springboot成神之——swagger文档自动生成工具

    本文讲解如何在spring-boot中使用swagger文档自动生成工具 目录结构 说明 依赖 SwaggerConfig 开启api界面 JSR 303注释信息 Swagger核心注释 User T ...

  6. 基于数据库的代码自动生成工具,生成JavaBean、生成数据库文档、生成前后端代码等(v6.0.0版)

    TableGo v6.0.0 版震撼发布,此次版本更新如下: 1.UI界面大改版,组件大调整,提升界面功能的可扩展性. 2.新增BeautyEye主题,界面更加清新美观,也可以通过配置切换到原生Jav ...

  7. C# 代码自动生成工具

    开源:C# 代码自动生成工具,支持站点前后台   前言 写这个项目有很长一段时间了,期间也修修改改,写到最后,自己也没咋用(研究方向变化了). 正文 具体项目开源了:https://github.co ...

  8. iBatis 代码自动生成工具 iBator 及 Example 使用

    iBator的下载和安装 官方下载地址:http://people.apache.org/builds/ibatis/ibator/ 安装:见<Eclipse 插件安装> 安装完成后,“F ...

  9. CoolPlist 帧动画自动生成工具

    工具英文名称:CoolPlist作者: 陈前帆 thinkingMan | sonny 邮箱: 625936034@qq.com | chenqianfan1@163.com电话: 136704713 ...

随机推荐

  1. iOS-KVO(转)

    参考学习网址:http://blog.sina.com.cn/s/blog_71715bf8010166ut.html KVO就是NSKeyValueObserving的缩写,它也是Foundatio ...

  2. iOS-系统bool理解

    typedef signed char BOOL; #if !defined(YES)    #define YES (BOOL)1 #endif #if !defined(NO)    #defin ...

  3. 如何去除PATH里的重复项并排序

    注意sed的用法,linux和Mac os不同,linux是Gnu的,Mac是BSD的 PATH排序去掉重复内容 mac和linux的换行符替换方法不一样,如下是Mac下的操作 export PATH ...

  4. Soda Machine【差分+离散化】

    题目链接:https://ac.nowcoder.com/acm/contest/1106/A 题目大意: 1.一条长1e9的线段,每个节点都可以上色.给出n次操作,每次操作将[l, r]区间内的节点 ...

  5. React native 放大点击区域 hitSlop属性的使用

    在日常的需求中,如上图的加减按钮,可能写ui布局的时候没考虑实际的这个点击范围太小,不利于真机上用户点击到,如果加包裹层加padding的话又会影响原先定好的布局,或者不利于对齐. 那么可以用  hi ...

  6. [转帖]详解shell脚本括号区别--$()、$「 」、$「 」 、$(()) 、「 」 、「[ 」]

    详解shell脚本括号区别--$().$「 」.$「 」 .$(()) .「 」 .「[ 」] 原创 波波说运维 2019-07-31 00:01:00 https://www.toutiao.com ...

  7. 在Ubuntu中安装了MongoDB后无法启动mongod的问题

    今天准备学习MongoDB,没想到下载之后服务器端启动不了,记录一下问题和处理过程 一.安装 在Ubuntu中安装还是很简单,直接:sudo apt install mongodb 二.启动 启动Mo ...

  8. gin mongodb restful api设计: 动态的patch接口

    目录 什么是Patch? Patch方法可以用来更新资源的一个组成部分 什么时候使用Patch? 当你仅需更新资源的某一项,即不完全也不幂等 那当我们的模型在数据库中几乎每个字段都可能会遇到改变的时候 ...

  9. Core使用SAP Web Service

    .Net Core在使用SAP的Web Service会遭遇到一些错误,貌似目前并不支持SAP中的Web Service,我们需要曲线实现下调用过程: 经测试,不再需要Framework项目中转,Sy ...

  10. python中集合set,字典dict和列表list的区别以及用法

    python中set代表集合,list代表列表,dict代表字典 set和dict的区别在于,dict是存储key-value,每一个key都是唯一的,set相对于dict存储的是key,且key是唯 ...