Reputation: 1
I am trying to run testng.xml from command prompt. This is the command I'm running:
C:\Users\sathmakur>java -cp C:\Users\sathmakur\.m2\repository\org\testng\testng\
6.3.1\testng-6.3.1.jar org.testng.TestNG test.xml
I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/ ParameterException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterExcep tion
at java.net.URLClassLoader$1.run(Unknown Source)
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)
... 6 more
I'm new at using TestNG and Command Prompt. It would be a great help if someone could shed some light.
Upvotes: 0
Views: 8545
Reputation: 1
From the stack it is clear that the essential jar file named jcommander-x.xx.jar is missing from the class path. Add this jar file to class path and your command line execution should work.
Upvotes: 0
Reputation: 11
Steps to run TestNG class in command prompt
open command prompt and type the below command
java -cp bin;jars/* org.testng.TestNG testng.xml
or
open notepad and type the above command and save as .bat file,double click on bat file.
Upvotes: 1
Reputation: 124
Saritha,
The easier way is to include that testng.xml in your pom.xml. Maven Surefire plugin can be configured for the same. Refer to this link http://docs.codehaus.org/display/MAVENUSER/Maven2+And+TestNG.Example+pom.xml (Observe the suitexmlfile tag). Once you include your testng.xml. All you have to do is call "mvn test" from the command prompt.
Upvotes: 0