How to run TestNG suite from command line

2019-08-28 08:35发布

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条回答
干净又极端
2楼-- · 2019-08-28 09:09

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

查看更多
登录 后发表回答