0

I am getting below error while executing testng.xml through command prompt Error : Could not find or load main class org.testng.TestNG

D:\>cd D:\Test\20July2018\test_automation\test_Framework\TestAutomation

D:\Test\20July2018\test_automation\test_Framework\TestAutomation>set projectLocation=D:\Test\20July2018\test_automation\test_Framework\TestAutomation

D:\Test\20July2018\test_automation\test_Framework\TestAutomation>cd %projectLocation%

D:\Test\20July2018\test_automation\test_Framework\TestAutomation>set classpath=%projectLocation%\bin;%projectLocation%\Ivy\*

D:\Test\20July2018\test_automation\test_Framework\TestAutomation>java org.testng.TestNG %projectLocation%\config\testrun_config.xml
Error: Could not find or load main class org.testng.TestNG

Let me know what I am making mistake.

Thanks Prashant

Prashant
  • 1,351
  • 3
  • 20
  • 32
  • look at this https://stackoverflow.com/questions/17894938/getting-error-could-not-find-or-load-main-class-org-testng-testng possible duplication – Kovacic Jul 20 '18 at 10:14
  • Possible duplicate of [Getting error Could not find or load main class org.testng.TestNG](https://stackoverflow.com/questions/17894938/getting-error-could-not-find-or-load-main-class-org-testng-testng) – Kovacic Jul 20 '18 at 10:14
  • i have tried above solutions but not working so I raised it again. – Prashant Jul 20 '18 at 10:21
  • How is your dependecy being handled: 1.directly via download jar, 2. via maven, 3. via gradle, something else? – Kovacic Jul 20 '18 at 10:24
  • Can you include sample of your testng.xml file. Also check the correct syntax would be : java -cp org.testng.TestNG testng.xml – anshul Gupta Jul 20 '18 at 10:26
  • I am using ant/Ivy based project – Prashant Jul 20 '18 at 10:27
  • Hey Anshul, I tried it but no luck – Prashant Jul 20 '18 at 12:09
  • AFAIK, you can't use wildcards in the `CLASSPATH` environment variable (which you shouldn't be using anyway). Instead try specifying the classpath on the `java` command using `-cp `. – Mark Rotteveel Jul 21 '18 at 11:49
  • Possible duplicate of [Error executing testng.xml through CLI : Could not find or load main class org.testng.TestNG](https://stackoverflow.com/questions/49149724/error-executing-testng-xml-through-cli-could-not-find-or-load-main-class-org-t) – undetected Selenium Jul 23 '18 at 12:15

0 Answers0