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

后端 未结 6 1055
不思量自难忘°
不思量自难忘° 2020-12-03 15:35

I\'m trying to run TestNG from command line, but it\'s giving me error. Can someone tell me where am I going wrong?

java -cp C:/TestNG directory

相关标签:
6条回答
  • 2020-12-03 16:08
    1. Try above answers.
    2. If still not work, then you might have downloaded the wrong version of testng.jar. From link testng.org, please click "here for ant users" to download a full testng.jar(11 mega bytes), not a "Maven Central" version(no more than 100k).

    I have tested those two versions on centos following testng tutorial point

    0 讨论(0)
  • 2020-12-03 16:08

    Check that the lib folder contains testng-6.8.jar(or any other version) file because testng.xml even executes successfully without testng-6.8.jar (or any other version) with the jars that gets added when we add TestNG library.

    0 讨论(0)
  • 2020-12-03 16:12
    1. Copy the below commands in a text file.

    2. Edit the location.

    3. Save it as yourtext.bat

    4. Now, double click on the batch file created.

    cd C:\Workspace\projectname

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

    0 讨论(0)
  • 2020-12-03 16:14

    Possibly your testng.jar file is not in the lib folder that C:\Workspace\projectname\lib.

    You should find testng.jar first in your computer and move it manually to C:\Workspace\projectname\lib. Then it will work

    0 讨论(0)
  • 2020-12-03 16:24

    Path of TestNG.jar file was not set up. Follow instructions of following site to set up. It worked for me: http://qtp-automate.blogspot.com/2011/10/running-selenium-testng-test-from.html

    0 讨论(0)
  • 2020-12-03 16:32

    My Assumptions:

    1. You are trying to run test file from command prompt

    2. libs folder generated under Project/tagret upon using "mvn clean package -DskipTests"

    3. class file generated under Project/target/test-classes/package-name

    With above assumptions in mind, you can follow below process.

    Setting class path in command prompt:

    1. Open project location in command prompt
    
    
    2. set classpath=C:\User\SeleniumTestProject\target\test-classes;C:\User\SeleniumTestProject\target\libs\*
    
    3. java org.testng.TestNG C:\User\SeleniumTestProject\testng.xml
    
    0 讨论(0)
提交回复
热议问题