【问题标题】:How to run TestNG suite from command line如何从命令行运行 TestNG 套件
【发布时间】:2013-04-24 18:29:37
【问题描述】:

我想在Linux 上从命令行运行TestNG Suite。我正在使用eclipse 运行测试,但我遇到了命令行问题。我知道我需要 testng.jar 并且我在 /home/karcio/dev/testng-6.4.jar 中有它,我的套件 xml 的位置是 /home/karcio/git/java-test-automation/Automation/test-output/Default suite/TestSuite.xml 。命令我尝试过的,

  1. 设置类路径/home/karcio/dev/testng-6.4.jar
  2. cd /location 到我的套件 xml 文件:java org.testing.TestNG TestSuite.xml

这是我看到的错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/testing/TestNG Caused by: java.lang.ClassNotFoundException: org.testing.TestNG

我是那些路径和类路径的新手,我有点困惑:(

谢谢

小更新, 我想我做得很好,现在当我进入终端时:java org.testng.TestNG Test.xml 我遇到了这个错误:

线程“主”org.testng.TestNGException 中的异常:没有源目录 在 org.testng.TestNG.checkConditions(TestNG.java:1170) 中指定 在 org.testng.TestNG.privateMain(TestNG.java:1010) 在 org.testng.TestNG.main(TestNG.java:997)

所有路径都已导出,所以可能这是testng.jar 的错误版本,尝试使用版本5.56.46.56.66.7,但我认为只有版本5.5 是工作,

【问题讨论】:

  • 你是先编译你的java类吗?我建议考虑使用 Ant 编译和运行您的套件。
  • 是的。我还为我的类文件(/bin/*class)导出了 CLASSPATH。我读到“没有指定源目录”我应该删除 java doc,但我没有创建任何 :(
  • 您的命令中有输入错误。它应该是 testng 而不是测试

标签: selenium command-line webdriver testng


【解决方案1】:

类包中有错字 org.testing.TestNG

应该是 org.testng.TestNG

(.testng. 部分没有 i)

http://testng.org/javadoc/org/testng/TestNG.html

【讨论】:

  • 嗨,patrungel thx。我打错了,但在导出类路径后,我使用了自动完成选项卡,所以现在我没有任何错误。
猜你喜欢
  • 2015-11-25
  • 2012-08-07
  • 1970-01-01
  • 2014-11-02
  • 2015-05-09
  • 2012-05-10
  • 1970-01-01
  • 2018-04-26
  • 2019-07-02
相关资源
最近更新 更多