To fix this follow below steps:-
Applicable for linux/unix and mac-os
you can map it to windows accordingly
Check JAVA_HOME
is correctly specified or not, if not do export JAVA_HOME=<java home dir>
execute echo $JAVA_HOME
and add variable in system PATH
export PATH=$PATH:$JAVA_HOME/bin
Click on link . to download Randoop, extract on your system.
Setup RANDOOP_PATH
and RANDOOP_JAR
as environment variable and add in system PATH
.
export RANDOOP_PATH=
export RANDOOP_JAR=$RANDOOP_PATH/randoop-all-.jar
export PATH=$RANDOOP_PATH:$RANDOOP_JAR:$PATH
goto and create /bin/src/main/java
and /bin/src/test/java
folders
Open Terminal and execute command java -ea -classpath $RANDOOP_JAR randoop.main.Main help
expected output
Randoop for Java version .
Randoop is a command-line tool that creates unit tests for Java. It
accepts one of the commands listed below. For the user manual, please
visit https://randoop.github.io/randoop/manual/index.html
Type `help' followed by a command name to see documentation.
Commands:
gentests -- Generates unit tests for a set of classes.
help -- Displays a help message for a given command.
Randoop setup is completed and ready to use.
- If you want to execute Randoop on class XYZ to generate test case follow below steps
6.1 XYZ.class
is class file having package name as com.demo
then create the folder /com/demo
under $RANDOOP_HOME/bin/src/main/java/
i.e. $RANDOOP_HOME/bin/src/main/java/com/demo/
and place XYZ.class
file here.
6.2 Now execute below command from terminal
java -ea -classpath $RANDOOP_PATH/bin/src/main/java:$RANDOOP_JAR:$JAVA_HOME/bin randoop.main.Main gentests --testclass=com.demo.XYZ --timelimit=60 --outputlimit=500 --inputlimit=500 --testsperfile=500 --error-test-basename=XYZError --regression-test-basename=XYZRegression --junit-package-name=com.demo --junit-output-dir=$RANDOOP_PATH/bin/src/test/java
6.3 Once 6.2 is completed goto $RANDOOP_PATH/bin/src/test/java
and verify the files are created or not!!!
6.4 now you can execute this Tests with Junit.jar
.