Randoop on windowns -No class with the name "ParserConfigurationSettings" found on the classpath

2.9k views Asked by At

Hello I'm getting the following erro after put the following command in the MS-DOS:

    C:\Users\Aline\Desktop\ClassesdoEstudodeCaso\ProjetosSelecionados\xerces-2.10.0\bin\org\apache\xerces\util>java -ea -classpath randoop.jar randoop.main.Main gentests --testclass=ParserConfigurationSettings --timelimit=60

policy = sun.security.provider.PolicyFile@10f87f48
    Error: No class with name "ParserConfigurationSettings" found on the classpath
           This is most likely a problem with the classpath. It may be wrong, or
           it is formatted incorrectly on the command line. The other possibility
           is that the wrong class name is given.
    Exiting Randoop.

And the "C:\Users\Aline\Desktop\ClassesdoEstudodeCaso\ProjetosSelecionados\xerces-2.10.0\bin\org\apache\xerces\util" already is in the classpath

3

There are 3 answers

0
mernst On

As stated in the Randoop error message that you quoted, you have specified the classpath incorrectly.

Your command line contains -classpath randoop.jar. This classpath does not contain the class ParserConfigurationSettings.

As shown in the Running Randoop section of the Randoop Manual, the classpath needs to contain both Randoop and the code being tested.

1
FilipeCavalcante On

I tried the command

java -ea -classpath randoop.jar;C:\Users\Aline\Desktop\ClassesdoEstudodeCaso\ProjetosSelecionados\xerces-2.10.0\bin\org\apache\xerces\util\ randoop.main.Main gentests --testclass=ParserConfigurationSettings --timelimit=10

But it didn't work, trying some other commands I found this one that worked:

java -ea -classpath randoop.jar;C:\Users\Aline\Desktop\ClassesdoEstudodeCaso\ProjetosSelecionados\xerces-2.10.0\bin\ randoop.main.Main gentests --testclass=org.apache.xerces.util.ParserConfigurationSettings --timelimit=60
1
Vishal Ghanwat On

To fix this follow below steps:-

Applicable for linux/unix and mac-os

you can map it to windows accordingly

  1. 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

  2. Click on link . to download Randoop, extract on your system.

  3. 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

  4. goto and create /bin/src/main/java and /bin/src/test/java folders

  5. 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.

  1. 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.