Re: [testng-users] How to run testng.xml file from command prompt.

3,125 views
Skip to first unread message

Yevhen Bilevych

unread,
May 22, 2013, 3:00:36 AM5/22/13
to testng...@googlegroups.com
TestNG jar is not in your CLASSPATH

You can either:
- put testng-X.Y.Z.jar into directory of your CLASSPATH:
- extend CLASSPATH to include that jar;
- add command line parameter -cp;

Thanks,
Yevhen

On 05/22/2013 06:22 AM, Omkar Khatavkar wrote:
> Hi All,
>
> I am running my testng.xml file from command prompt mention in site
> http://testng.org/doc/documentation-main.html#running-testng
>
> but getting an as :Error: Could not find or load main class
> org.testng.TestNG
>
> Could some one face this problem.Please provide the answer for this.
> --
> You received this message because you are subscribed to the Google
> Groups "testng-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to testng-users...@googlegroups.com.
> To post to this group, send email to testng...@googlegroups.com.
> Visit this group at http://groups.google.com/group/testng-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Krishnan Mahadevan

unread,
May 22, 2013, 3:25:57 AM5/22/13
to testng...@googlegroups.com
Maybe you are missing specifying the classpath to where your TestNG.jar exists




Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

Omkar Khatavkar

unread,
May 25, 2013, 2:57:27 AM5/25/13
to testng...@googlegroups.com
I did added class path but still getting error as

E:\Omkar\AutomationAtHome\
DeskeraApps>java org.testng.TestNG testng.xml
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
--
Thanks and Regards,
 Omkar Khatvakar

Omkar Khatavkar

unread,
May 25, 2013, 5:07:45 AM5/25/13
to testng...@googlegroups.com
Now i am getting an error like below

E:\Omkar\Automation\TestNG>java -cp "e:\Omkar\Automation\TestNG\testng.jar" org.testng.TestNG testng.xml
[TestNG] [ERROR]
Cannot find class in classpath: classes.Test1

Omkar Khatavkar

unread,
May 26, 2013, 7:02:26 AM5/26/13
to testng...@googlegroups.com
After Executing


E:\Omkar\Automation\TestNG>java -cp C:\Users\Shree\.m2\repository\org\testng\testng\6.1.1\testng
-6.1.1.jar;E:\Omkar\Automation\TestNG\selenium-server-standalone-2.33.0.jar org.testng.TestNG te
stng.xml
[TestNG] [ERROR]
Cannot find class in classpath: omkar.Test1


My Testng xml file :


<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="false">

    <test name="Test 1">
        <classes>
            <class name="omkar.Test1" />
        </classes>
    </test>
    <test name="Test 2">
        <classes>
            <class name="omkar.Test2" />
        </classes>
    </test>
</suite>


Can any one help me out here, I did added classpath but not able to solve the problem.Also searched whole on stack overflow still did not able to solve this.

Yevhen Bilevych

unread,
May 26, 2013, 8:14:50 AM5/26/13
to testng...@googlegroups.com
Omkar, 

You may run tests from your working directory (where your package with tests resides).

Sent from my BlackBerry® PlayBook™
www.blackberry.com


From: "Omkar Khatavkar" <okhata...@gmail.com>
To: "testng...@googlegroups.com" <testng...@googlegroups.com>
Sent: May 26, 2013 2:02 PM
Subject: Re: [testng-users] How to run testng.xml file from command prompt.

Omkar Khatavkar

unread,
May 26, 2013, 11:10:20 PM5/26/13
to testng...@googlegroups.com
Hi Yevhen,

I ran tests from from working directory from package where tests are present but still getting same error

E:\Omkar\Automation\TestNG\bin\omkar>java -classpath E:\Omkar\Automation\TestNG\testng.jar org.testng
.TestNG "E:\Omkar\Automation\TestNG\testng.xml"
[TestNG] [ERROR]
Cannot find class in classpath: omkar.Test1

Cédric Beust ♔

unread,
May 26, 2013, 11:17:32 PM5/26/13
to testng...@googlegroups.com
Find a classpath that will allow you to run "javap" on your class name. Once you have that, use it for TestNG.


-- 
Cédric

Reply all
Reply to author
Forward
0 new messages