Randoop на ветру - Нет класса с именем "ParserConfigurationSettings", найденного на пути к классам
Здравствуйте, я получаю следующее сообщение об ошибке после ввода следующей команды в 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.
И "C:\Users\Aline\Desktop\ClassesdoEstudodeCaso\ProjetosSelecionados\xerces-2.10.0\bin\org\apache\xerces\util" уже находится в пути к классам
3 ответа
Я попробовал команду
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
Но это не сработало, попробовав другие команды, я нашел эту, которая сработала:
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
Как указано в сообщении об ошибке Randoop, которое вы цитировали, вы неправильно указали путь к классу.
Ваша командная строка содержит -classpath randoop.jar
, Этот classpath не содержит класс ParserConfigurationSettings
,
Как показано в разделе " Запуск Randoop " Руководства по Randoop, путь к классам должен содержать как Randoop, так и код, который тестируется.
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 https://randoop.github.io/randoop/manual/ . 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=<randoop home dir>
export RANDOOP_JAR=$RANDOOP_PATH/randoop-all-<version>.jar
export PATH=$RANDOOP_PATH:$RANDOOP_JAR:$PATH
4. goto <randoop home dir> 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 <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.**
6. 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.