How to run TestNG suite from command line

自闭症网瘾萝莉.ら 提交于 2020-01-16 19:01:09

问题


I would like to run TestNG Suite from command line on Linux. I'm using eclipse to run test, but I have problem with command line. I know that I need to have testng.jar and I have it in /home/karcio/dev/testng-6.4.jar, location my suite xml is /home/karcio/git/java-test-automation/Automation/test-output/Default suite/TestSuite.xml . Commands what I tried,

  1. set classpath /home/karcio/dev/testng-6.4.jar
  2. cd /location to my suite xml file: java org.testing.TestNG TestSuite.xml

This is error what I see:

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

I'm new in those path and classpath, I'm little bit confusing :(

Thank you

Little update, I think I did all good, now when I put to terminal: java org.testng.TestNG Test.xml I've got this error:

Exception in thread "main" org.testng.TestNGException: No sourcedir was specified at org.testng.TestNG.checkConditions(TestNG.java:1170) at org.testng.TestNG.privateMain(TestNG.java:1010) at org.testng.TestNG.main(TestNG.java:997)

all path are exported, so maybe this is wrong version of testng.jar, tried with versions 5.5, 6.4, 6.5, 6.6, 6.7 but I think only version 5.5 is working,


回答1:


There is a typo in the class package org.testing.TestNG

should be org.testng.TestNG

(There no i in the .testng. part)

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



来源:https://stackoverflow.com/questions/16199554/how-to-run-testng-suite-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!