简体   繁体   English

在windowns上运行-在类路径中找不到名称为“ ParserConfigurationSettings”的类

[英]Randoop on windowns -No class with the name “ParserConfigurationSettings” found on the classpath

Hello I'm getting the following erro after put the following command in the MS-DOS: 您好,在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\u0026quot; already is in the classpath 并且“ C:\\ Users \\ Aline \\ Desktop \\ ClassesdoEstudodeCaso \\ ProjetosSelecionados \\ xerces-2.10.0 \\ bin \\ org \\ apache \\ xerces \\ util”已经在类路径中

As stated in the Randoop error message that you quoted, you have specified the classpath incorrectly. 如引用的Randoop错误消息中所述,您没有正确指定类路径。

Your command line contains -classpath randoop.jar . 您的命令行包含-classpath randoop.jar This classpath does not contain the class ParserConfigurationSettings . 该类路径不包含ParserConfigurationSettings类。

As shown in the Running Randoop section of the Randoop Manual , the classpath needs to contain both Randoop and the code being tested. 如《 Randoop手册》的“ 运行Randoop”部分所示,类路径需要同时包含Randoop和要测试的代码。

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

To fix this follow below steps:- 要解决此问题,请执行以下步骤:-

Applicable for linux/unix and mac-os 适用于linux / unix和mac-os

you can map it to windows accordingly 您可以将其相应地映射到Windows

  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 检查是否正确指定了JAVA_HOME ,如果不正确,则导出JAVA_HOME=<java home dir>执行echo $JAVA_HOME并在系统PATH添加变量

    export PATH=$PATH:$JAVA_HOME/bin 导出PATH = $ PATH:$ JAVA_HOME / bin

  2. Click on link . 点击链接 to download Randoop, extract on your system. 要下载Randoop,请在您的系统上解压缩。

  3. Setup RANDOOP_PATH and RANDOOP_JAR as environment variable and add in system PATH . RANDOOP_PATHRANDOOP_JAR设置为环境变量,并添加系统PATH

    export RANDOOP_PATH= export RANDOOP_JAR=$RANDOOP_PATH/randoop-all-.jar export PATH=$RANDOOP_PATH:$RANDOOP_JAR:$PATH 出口RANDOOP_PATH =出口RANDOOP_JAR = $ RANDOOP_PATH / randoop-all-.jar出口PATH = $ RANDOOP_PATH:$ RANDOOP_JAR:$ PATH

  4. goto and create /bin/src/main/java and /bin/src/test/java folders 转到并创建/bin/src/main/java/bin/src/test/java文件夹

  5. Open Terminal and execute command java -ea -classpath $RANDOOP_JAR randoop.main.Main help 打开终端并执行命令java -ea -classpath $RANDOOP_JAR randoop.main.Main help

expected output 预期产量

Randoop for Java version . Randoop for Java版本。

Randoop is a command-line tool that creates unit tests for Java. Randoop是一个命令行工具,可为Java创建单元测试。 It accepts one of the commands listed below. 它接受下面列出的命令之一。 For the user manual, please visit https://randoop.github.io/randoop/manual/index.html 有关用户手册,请访问https://randoop.github.io/randoop/manual/index.html

Type `help' followed by a command name to see documentation. 键入“ help”,后跟命令名称以查看文档。

Commands: 命令:

gentests -- Generates unit tests for a set of classes. gentests-为一组类生成单元测试。

help -- Displays a help message for a given command. help-显示给定命令的帮助消息。

Randoop setup is completed and ready to use. Randoop设置已完成并可以使用。

  1. If you want to execute Randoop on class XYZ to generate test case follow below steps 如果要在类XYZ上执行Randoop以生成测试用例,请执行以下步骤

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/ ie $RANDOOP_HOME/bin/src/main/java/com/demo/ and place XYZ.class file here. 6.1 XYZ.class是具有包名称为com.demo类文件,然后在$RANDOOP_HOME/bin/src/main/java/下创建文件夹/com/demo ,即$RANDOOP_HOME/bin/src/main/java/com/demo/并将XYZ.class文件放在这里。

6.2 Now execute below command from terminal 6.2现在从终端执行以下命令

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.3 6.2完成后,转到$RANDOOP_PATH/bin/src/test/java并验证是否创建了文件!

6.4 now you can execute this Tests with Junit.jar . 6.4现在,您可以使用Junit.jar执行此测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM