无法从命令行运行TestNG。

huangapple 未分类评论44阅读模式
英文:

Cannot run TestNG from command line

问题

我正尝试通过命令行运行testng.xml文件。我在根项目的lib文件夹中有testng7.2.jar和JCommander jar文件。

我以以下方式设置类路径:

set classpath=C:\Users\test-automation\bin;C:\Users\test-automation\lib\*

lib文件夹中包含以下jar文件:

com.beust.jcommander_1.72.0.jar
org.apache-extras.beanshell.bsh_2.0.0.b6.jar
org.testng_7.2.0.r202003151902.jar
org.yaml.snakeyaml_1.21.0.jar

我正在运行以下命令来从命令提示符中执行testng。

java -Dtestng.dtd.http=true org.testng.TestNG C:\Users\test-automation\testng.xml

但是出现了以下错误:

[TestNG] [ERROR]
在类路径中找不到类: main.IConductorRunner

TestNG套件在Eclipse控制台上可以完美运行。但是当我尝试从命令行(Windows命令提示符)运行时,出现了上述错误。由于我对TestNG不太熟悉,不确定该如何处理。

英文:

I am trying to run testng.xml from command line. I have testng7.2.jar and JCommander jar file in the lib folder of the root project.

I am setting the classpath in the following way:

set classpath=C:\Users\test-automation\bin;C:\Users\test-automation\lib\*

The lib folder has the following jar files:

com.beust.jcommander_1.72.0.jar
org.apache-extras.beanshell.bsh_2.0.0.b6.jar
org.testng_7.2.0.r202003151902.jar
org.yaml.snakeyaml_1.21.0.jar

I am running the following command to execute testng from command prompt.

java -Dtestng.dtd.http=true org.testng.TestNG C:\Users\test-automation\testng.xml

But getting the following error:

[TestNG] [ERROR]
Cannot find class in classpath: main.IConductorRunner

TestNG suite runs perfectly from eclipse console. But when I try to do so from command line (windows command prompt), I get the above error. Not sure what to do excactly as I am new to testng.

答案1

得分: 0

除了测试逻辑编码的测试类之外,您的类路径中已经包含了所有内容。将测试类的路径添加到其中,以便 TestNG 知道从哪里获取测试代码。

英文:

You have everything in your classpath except of your test classes where your test logic is coded. Add the path to your test classes to that TestNG knows where to take the test code.

huangapple
  • 本文由 发表于 2020年7月25日 03:21:34
  • 转载请务必保留本文链接:https://java.coder-hub.com/63080219.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定