- Java 8
- Maven
Go here https://github.com/EvoSuite/evosuite/releases/tag/v1.1.0 and download the two JAR files:
evosuite-1.1.0.jar
contains the entire EvoSuite logic for generating testsevosuite-standalone-runtime-1.1.0.jar
contains the dependencies needed by the JUnit tests generated by EvoSuite
Place them in any directory you want (e.g., your home directory).
- Run
git clone https://github.com/EvoSuite/evosuite
- Run
cd evosuite
- Run
mvn package -DskipTests
to generate - Run
cp master/target/evosuite-master-1.1.1-SNAPSHOT.jar ~/evosuite-1.1.1.jar
- Run
cp standalone_runtime/target/original-evosuite-standalone-runtime-1.1.1-SNAPSHOT.jar ~/evosuite-standalone-runtime-1.1.1.jar
In this examples EvoSuite 1.1.0 is already downloaded and part of this repository.
- Run
git clone https://github.com/sesalab/evosuite-examples
- Run
cd evosuite-examples
- Run
java -jar evosuite-1.1.0.jar
to check if everything works well (you should see a text output on the terminal). - Run
cd Tutorial_Stack
- Run
mvn compile test-compile
to get the .class of the class under test, i.e.,tutorial.Stack
- Run
java -jar ../evosuite-1.1.0.jar -class tutorial.Stack -projectCP target/classes
to start the generation with default setting (60 seconds of budget). You can kill the process at anytime by issuingCTRL+C
- Run
mvn dependency:copy-dependencies
to copy JUnit and Hamcrest JARs intotarget/dependency
(you can avoid this step if you can find these JAR in.m2/
directory) - Run
javac -cp .:target/classes:../evosuite-standalone-runtime-1.1.0.jar:target/dependency/junit-4.12.jar:target/dependency/hamcrest-core-1.3.jar -d target/test-classes evosuite-tests/tutorial/*.java
to compile the tests inevosuite-tests/tutorial
and place them intarget/test-classes
- Run
java -cp .:target/classes:target/test-classes:../evosuite-standalone-runtime-1.1.0.jar:target/dependency/junit-4.12.jar:target/dependency/hamcrest-core-1.3.jar org.junit.runner.JUnitCore tutorial.Stack_ESTest
to execute all the JUnit test methods generated by EvoSuite.
You should see all tests pass (OK).
Repeat the above steps but change the 6th one with the following:
- Run
java -jar ../evosuite-1.1.0.jar -class tutorial.Stack -projectCP target/classes -criterion branch -Dsearch_budget=20 -Dminimize=false
to start the generation with default setting (60 seconds of budget).
Checkout all the possible settings with java -jar ../evosuite-1.1.0.jar -listParameters
Repeat the above steps but change the 6th one with the following:
java -jar ../evosuite-1.1.0.jar -target target/classes
to generate tests for all classes found intarget/classes
and its subdirectories. You can also add the option-prefix packageName
to specify which package you want to test.
- Seed a bug into Stack class (e.g., switch negate a logical operator)
- Run
mvn compile
to recompile Stack class - Run
java -cp .:target/classes:target/test-classes:../evosuite-standalone-runtime-1.1.0.jar:target/dependency/junit-4.12.jar:target/dependency/hamcrest-core-1.3.jar org.junit.runner.JUnitCore tutorial.Stack_ESTest
If you see at least one failure then the tests are not so bad!
- Seed a bug into Stack class (e.g., switch negate a logical operator)
- Run
mvn compile
to recompile Stack class - Run
java -jar ../evosuite-1.1.0.jar -class tutorial.Stack -projectCP target/classes
to regenerate the EvoSuite tests - Run
javac -cp .:target/classes:../evosuite-standalone-runtime-1.1.0.jar:target/dependency/junit-4.12.jar:target/dependency/hamcrest-core-1.3.jar -d target/test-classes evosuite-tests/tutorial/*.java
to compile the tests inevosuite-tests/tutorial
and place them intarget/test-classes
- Run
java -cp .:target/classes:target/test-classes:../evosuite-standalone-runtime-1.1.0.jar:target/dependency/junit-4.12.jar:target/dependency/hamcrest-core-1.3.jar org.junit.runner.JUnitCore tutorial.Stack_ESTest
to execute all the JUnit test methods generated by EvoSuite.
You will see that all tests pass, meaning that the assertions are build on the current behaviour of the class!