Getting an error. Could not find or load the main class org.testng.TestNG

I am trying to run TestNG from the command line, but this gives me an error. Can someone tell me where I am going wrong?

java -cp C: / TestNG directory / testng-6.2.jar; C: \ project directory \ src \ com \ suites \ suite \ shop org.testng.TestNG testng.xml

Error : could not find or load the main class org.testng.TestNG

My scripts work fine when I run them from the eclipse testng plugin .

+8
source share
6 answers
  • Copy the commands below into a text file.

  • Edit the location.

  • Save it as yourtext.bat

  • Now double click on the created batch file.

cd C: \ Workspace \ projectname

java -cp C: \ Workspace \ projectname \ lib *; C: \ Workspace \ project_name \ bin org.testng.TestNG testng.xml

+9
source

The path to the TestNG.jar file is not configured. Follow the instructions on the following site to configure. This worked for me: http://qtp-automate.blogspot.com/2011/10/running-selenium-testng-test-from.html

+3
source
  • Try the answer above.
  • If you are still not working, you may download the wrong version of testng.jar . From the testng.org link , click "here for ant users" to download the full version of testng.jar (11 megabytes), and not the "Maven Central" version (no more than 100 thousand).

I tested these two versions on centos following the testng test

+1
source

Your testng.jar file may not be in the lib folder, which is C:\Workspace\projectname\lib .

First you have to find testng.jar on your computer and transfer it manually to C:\Workspace\projectname\lib . Then it will work

+1
source

Make sure that the lib folder contains the file testng-6.8.jar (or any other version), since testng.xml even succeeds without testng-6.8.jar (or any other version) with jar files that are added when the TestNG library is added.

0
source

I used the below command CD C: \ EIT-Framework \ EIT

Java -cp C: project \ library name *; C: project name \ bin org.testng.TestNG Mat.xml

still not working for me can someone help me with this

0
source

Source: https://habr.com/ru/post/950411/


All Articles