How exactly do I run a .java TestNG project from a command line?
I have read through the TestNG documentation, and tried the following to no avail:
C:\projectfred> java org.testng.TestNG testng.xml
... with the following testng.xml file in my project:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="SuiteAll" verbose="1">
<test name="TestAll">
<packages>
<package name="com.project.fred.tests"/>
</packages>
</test>
</suite>
The error I get is this:
Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNG
Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.testng.TestNG. Program will exit.
Obviously, I am not referencing TestNG correctly in my command line. Does anyone know how to get this working?
Using " ; " as delimiter on windows issue got resolved.
ex:-
Ok after 2 days of trying to figure out why I couldn't run the example from
http://www.tutorialspoint.com/testng/testng_environment.htm the following code did not work for me
The fix for it is as follows: I came to the following conclusion: First off install eclipse, and download the TestNG plugin. After that follow the instructions from the tutorial to create and compile the test class from cmd using javac, and add the testng.xml. To run the testng.xml on windows 10 cmd run the following line:
to clarify:
C:\Users\Lenovo\Desktop\eclipse\plugins\org.testng.eclipse_6.9.12.201607091356\lib\*
The path above represents the location of jcommander.jar and testng.jar that you downloaded by installing the TESTNG plugin for eclipse. The path may vary so to be sure just open the installation location of eclipse, go to plugins and search for jcommander.jar. Then copy that location and after that add * to select all the necessary .jars.The path above represents the location of the testing.xml in your project. After getting all the necessary paths, append them by using ";".
I hope I have been helpful to some of you guys :)