- Create a new Maven project
- Create a peice of java code under
src/main/java
, e.g,codeToTest.java
- Create a junit script under
src/test/java
, e.g,codeToTestTest.java
- Modify the your
pom.xml
like pom.xml. - Dowload all dependencies
- Click
Run
then clickEdit Configuration
- Find
Code Coverage
- Select
Jacoco
- First get in the directory of your maven project
- Run
mvn evosuite:generate
, you will find the generated tests under.evosuite
- By running
mvn evosuite:generate evosuite:export
, the tests will be generated automatically undersrc/test/java
- Go to Plugin Market and search EvoSuite
- Install
EvoSuite Plugin
and restart IDEA IDE - Right click the junit script and select
Run EvoSuite
- Customize your configuration.
4.1 Maven location: for ubuntu:
/usr/share/maven/bin/mvn
(install by apt install maven) 4.2 JAVA_HOME
After all these steps, you will get two java file
*_ESTest
*_ESTest_scaffolding
Just discard*_ESTest_scaffolding
, it is useless. And comment@RunWith*
andextends *_ESTest_scaffolding
. Or copy the generated test scripts to your own file.
Thank you!