2016-12-29 101 views
0

你好,我發現了以下埃羅放在MS-DOS下面的命令後:Randoop上WINDOWNS - 無類在類路徑中找到名爲「ParserConfigurationSettings」

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 = [email protected] 
    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「已經在類路徑中

回答

0

正如在引用的Randoop錯誤消息中所述,類路徑不正確。

您的命令行包含-classpath randoop.jar。此類路徑不包含類ParserConfigurationSettings

Randoop ManualRunning Randoop部分所示,類路徑需要同時包含Randoop和正在測試的代碼。

+0

感謝您的幫助 – FilipeCavalcante

0

我試着命令

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 
+0

類路徑總是包含你期望看到包名稱的第一部分(例如'org')作爲子目錄的目錄,並且Randoop希望類名由包名完全限定。所以,第一個在兩個方面都有缺陷。 – vinegarbin

0
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. 
+0

嗨!看起來你的整篇文章被格式化爲代碼,請嘗試使用以下指南進行格式化:https://stackoverflow.com/help/formatting以使其更具可讀性。 –

相關問題