【问题标题】:How to run TestNG with command line如何使用命令行运行 TestNG
【发布时间】:2014-11-02 10:22:36
【问题描述】:

我正在使用 TestNG 框架在 Selenium 中运行测试用例。通过eclipse我可以一起运行所有的xml,但是如何通过命令行或者bat文件运行呢。

我试过了

start java -ea -Dfile.encoding=Cp1252 -classpath "/D:/Eclipse 3.6.2/eclipse/plugins/org.testng.eclipse_6.8.6.20141201_2240/lib/testng.jar;D:\XML\SpringIntegration_NIC\new_temp\bin;D:\XML\SpringIntegration\lib\SeleniumServer.jar;D:\XML\SpringIntegration\lib\selenium-server-standalone-2.37.0.jar;D:\XML\SpringIntegration\lib\selenium-java-2.37.0.zip;D:\XML\SpringIntegration_NIC\new_temp\lib\sikuli-script.jar;D:\XML\SpringIntegration_NIC\new_temp\lib\sikuli-ide.jar;D:\XML\SpringIntegration_NIC\new_temp\build.xml" org.testng.remote.RemoteTestNG -serport 28844 -d D:\XML\SpringIntegration_NIC\new_temp\test-output D:\XML\SpringIntegration_NIC\new_temp\TestNG_parallel.xml

这是从 Eclipse 运行时 Eclipse 如何给出的命令。我试过了,但有一段时间它在运行,大部分时间都没有运行。

【问题讨论】:

标签: selenium command-line selenium-webdriver testng


【解决方案1】:
  1. 使用命令行导航到您的项目目录。像这样设置项目路径:

C:\projects\Selenium_Project set ProjectPath = C:\projects\Selenium_Project

  1. 创建一个应该指向 seleniu/testng 类文件和 jar 文件的类路径。

C:\projects\Selenium_Project set classpath = %ProjectPath%\bin;%ProjectPath%\Lib\*

其中 \bin 指向类文件,\Lib 指向 jar 文件,如果您将 jar 文件保存在其他文件夹中,则仅指向该文件夹。

  1. 执行java命令运行

C:\projects\Selenium_Project java org.testng.TestNG %ProjectPath%\TestXml.xml

如果您使用的是 Eclipse IDE,上述解决方案将有效

【讨论】:

  • 是的,它正在运行,但不是整个套件测试用例,仅在套件运行之后和之前
  • 检查你的 testxml,它是否包含类定义?
  • 有关我的问题的更多详细信息,您可以查看吗? stackoverflow.com/questions/25765332/…
【解决方案2】:

请使用以下命令运行 testNg XML:

C:\TestNG_WORKSPACE>java -cp "C:\TestNG_WORKSPACE" org.testng.TestNG testng.xml

【讨论】:

    猜你喜欢
    • 2012-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-02
    • 2018-04-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多