- 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.jarcontains the entire EvoSuite logic for generating testsevosuite-standalone-runtime-1.1.0.jarcontains 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 -DskipTeststo 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.jarto check if everything works well (you should see a text output on the terminal). - Run
cd Tutorial_Stack - Run
mvn compile test-compileto 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/classesto start the generation with default setting (60 seconds of budget). You can kill the process at anytime by issuingCTRL+C - Run
mvn dependency:copy-dependenciesto 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/*.javato compile the tests inevosuite-tests/tutorialand 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_ESTestto 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=falseto 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/classesto generate tests for all classes found intarget/classesand its subdirectories. You can also add the option-prefix packageNameto specify which package you want to test.
- Seed a bug into Stack class (e.g., switch negate a logical operator)
- Run
mvn compileto 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 compileto recompile Stack class - Run
java -jar ../evosuite-1.1.0.jar -class tutorial.Stack -projectCP target/classesto 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/*.javato compile the tests inevosuite-tests/tutorialand 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_ESTestto 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!