如何使用命令行运行TestNG

时间:2014-09-09 05:18:22

标签: selenium command-line selenium-webdriver testng

我正在使用 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在从日食中运行时给出的命令。我已经尝试了一段时间它的运行,大部分时间没有运行。

2 个答案:

答案 0 :(得分:0)

  1. 使用命令行导航到项目目录。设置这样的项目路径:
  2. C:\projects\Selenium_Project set ProjectPath = C:\projects\Selenium_Project

    1. 创建一个应该指向seleniu / testng类文件和jar文件的类路径。
    2. C:\projects\Selenium_Project set classpath = %ProjectPath%\bin;%ProjectPath%\Lib\*

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

      1. 执行java命令以运行
      2. C:\projects\Selenium_Project java org.testng.TestNG %ProjectPath%\TestXml.xml

        如果您使用的是Eclipse IDE

        ,则上述解决方案将起作用

答案 1 :(得分:0)

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

C:\TestNG_WORKSPACE>java -cp "C:\TestNG_WORKSPACE" org.testng.TestNG testng.xml
相关问题