无法通过命令行执行TestNG Suite文件 [英] Unable to execute TestNG Suite file via command line

查看:381
本文介绍了无法通过命令行执行TestNG Suite文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过命令行执行TestNG Suite文件以启动回归运行. 当前,通过右键单击"testng.xml"文件,然后选择运行方式">"TestNG Suite",可以成功地通过Eclipse IDE进行此操作.

I am trying to execute a TestNG Suite file via the command line in order to initiate a regression run. Currently I am doing this through my Eclipse IDE successfully by right-click on the "testng.xml" file then selecting Run As > TestNG Suite.

但是,当我尝试通过命令行运行它时,出现一条错误消息.步骤如下:

However, when I try to run it via the command line, I get an error message. Steps below:

  • 我导航到保存"testng.xml"文件的目录.例如C:\ Users \ xxx \ Documents \ eclipse项目\ Automated Testing \ config
  • 运行命令:

  • I navigate to the directory where my "testng.xml" file is saved. e.g. C:\Users\xxx\Documents\eclipse projects\Automated Testing\config
  • Run the command:

java org.testng.TestNG testng.xml

上面的命令生成以下响应:

The above command generates the below response:

Error: Could not find or load main class org.testng.TestNG

  • 我尝试将类路径设置为包含所有硒和testNG Jar文件,如下所示:

    • I tried setting the classpath to include all of the selenium and testNG Jar files as per below:

      set classpath C:/Users/xxxx/Downloads/selenium-java-2.25.0/selenium-2.25.0/libs/*

      但是,这会生成以下错误消息:

      However, this generates the below error message:

      Environment variable classpath C:/Users/xxxx/Downloads/selenium-java-2.25.0/selenium- 2.25.0/libs/* not defined
      

      我查看了testNG文档( http://testng.org/doc/documentation- main.html ),这只是说testNG必须在您的类路径中,所以现在我有点卡住了.任何帮助将不胜感激.

      I have looked on the testNG Documentation (http://testng.org/doc/documentation-main.html) and this just says that testNG has to be in your classpath, so now I am a bit stuck. Any help would be greatly appreciated.

      推荐答案

      任何一种方法都可以工作:)

      Either methods work :)

      方法#1

      cd C:\Workspace\projectname
      java -cp C:\Workspace\projectname\lib\*;C:\Workspace\projectname\bin org.testng.TestNG testng.xml
      

      方法#2

      cd C:\Workspace\projectname
      set ProjectPath=C:\Workspace\projectname
      echo %ProjectPath%
      set classpath=%ProjectPath%\bin;%ProjectPath%\lib\*
      echo %classpath%
      java org.testng.TestNG %ProjectPath%\testng.xml
      

      这篇关于无法通过命令行执行TestNG Suite文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆