run suite programmatically

1,616 views
Skip to first unread message

Shantaram

unread,
Dec 28, 2009, 5:27:31 AM12/28/09
to testng...@googlegroups.com
Is there any way i can run my testng test xml programatically from java ?
I have gone throught the documentation related to running tests programmatically, but
in all the approaches given i need to supply the test/ suite objects or classes.

i need something like this

TestNG tng = new TestNG();
tng.setXmlSuites(<path of my testng xml>);
tng.run(); 


If there's no such feature available, any suggestion on how i should proceed with implementing it ?
Create my own testrunner ?

--
Thanks & Regards,

Shantaram Waingankar
9969035764
www.shantaram.co.in

Twenty years from now you will be more disappointed by the things you didn't do than by the ones you did do.
So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails.
Explore. Dream. Discover.

Cédric Beust ♔

unread,
Dec 28, 2009, 12:09:29 PM12/28/09
to testng...@googlegroups.com
Hi Shantaram,

On Mon, Dec 28, 2009 at 2:27 AM, Shantaram <svwain...@gmail.com> wrote:
Is there any way i can run my testng test xml programatically from java ?
I have gone throught the documentation related to running tests programmatically, but
in all the approaches given i need to supply the test/ suite objects or classes.

i need something like this

TestNG tng = new TestNG();
tng.setXmlSuites(<path of my testng xml>);
tng.run(); 


If there's no such feature available, any suggestion on how i should proceed with implementing it ?
Create my own testrunner ?


Did you read the following section of the documentation:


?

--
Cédric


abhishek uppala

unread,
Jan 7, 2010, 2:24:11 AM1/7/10
to testng...@googlegroups.com
Hi Cedric,

I have gone through the documentation provided at the link given by you. When I do it the same way, my test cases are not run.

Here is the output.

[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[WARNING] POM for 'org.codehaus.jackson:jackson-lgpl:pom:0.9.4:test' is invalid.

Its dependencies (if any) will NOT be available to the current build.
[compiler:compile]
No sources to compile
[exec:exec]
------------------------------------------------------------------------
BUILD SUCCESSFUL
------------------------------------------------------------------------
Total time: 2 seconds
Finished at: Thu Jan 07 12:46:49 IST 2010
Final Memory: 11M/20M
------------------------------------------------------------------------


My testng.xml file is:

<suite junit="false" name="TestNG Test" parallel="false" skipfailedinvocationCounts="false" thread-count="5">

<test annotations="JDK" junit="false" name="testng" verbose="5">
<classes>
             <class name="com.sample.abc"/>
</classes>
</test>

</suite>

java code:

XmlSuite suite=new XmlSuite();
        suite.setName("SelNG Test");
        List<XmlSuite> suites = new ArrayList<XmlSuite>();
        suites.add(suite);
        TestNG tng = new TestNG();
        tng.setXmlSuites(suites);
        tng.run();

Thanks
Abhishek Uppala

2009/12/28 Cédric Beust ♔ <cbe...@google.com>

--

You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Cédric Beust ♔

unread,
Jan 7, 2010, 2:28:23 AM1/7/10
to testng...@googlegroups.com

Can you try without Maven?

2009/12/28 Cédric Beust ♔ <cbe...@google.com>

> > Hi Shantaram, > > On Mon, Dec 28, 2009 at 2:27 AM, Shantaram <svwain...@gmail.com> wrote: >> ...

> -- > > You received this message because you are subscribed to the Google Groups "testng-users" gr...


Shantaram

unread,
Jan 7, 2010, 5:09:23 AM1/7/10
to testng...@googlegroups.com
hi abhishek,

I'm not very sure setXmlSuites is to be used the way you have implemented.
how would testNG know the file where it should look for the "SelNG Test" suite ?

This is how I used setTestSuites to supply my xml,
you can try that way.

        List<String> files = new ArrayList<String>();
        files.add("testng.xml");

        TestNG tng = new TestNG();
        tng.setTestSuites(files);
        tng.run();


--
Thanks & Regards,

Shantaram Waingankar
http://www.shantaram.co.in

Saba Software India Pvt. Ltd.
Mumbai, India
Cell      +91 9969035764

Small Loans, Big Impacts. Log on to www.rangde.org to make a social
investment today!


2010/1/7 Cédric Beust ♔ <cbe...@google.com>

--
Thanks & Regards,

Shantaram Waingankar

Saba Software India Pvt. Ltd.
Mumbai, India
Cell      +91 9969035764

Small Loans, Big Impacts. Log on to www.rangde.org to make a social
investment today!

abhishek uppala

unread,
Jan 7, 2010, 10:17:02 AM1/7/10
to testng...@googlegroups.com
Hi Shantaram

Thanks for pointing it out.I followed your way.

@Cedric
I was trying to work with TestNG in Netbeans6.7.1. I am able to create a test file but i see that there is no way of executing one/some of the @test methods,that is,there is no option for running tests in groups. I created testng.xml but yet it did not work out.

Is there any additional thing to be done for working with Netbeans or does Netbeans not support this feature?

Thanks
Abhishek Uppala

srinivas donthula

unread,
Jan 7, 2010, 6:59:47 AM1/7/10
to testng...@googlegroups.com
Hi,

I got the below error while running Java-selenium program by using TeshNG.

[org.testng.internal.PoolService] Shutting down poolservice org.testng.internal.PoolService@124bbbf terminated:false

Could you please help me in resolving above error?

Thanks,
Srinivas



On Thu, Jan 7, 2010 at 3:39 PM, Shantaram <svwain...@gmail.com> wrote:



--
Thanks & Regards,
 Srinivas.

Cédric Beust ♔

unread,
Jan 7, 2010, 11:22:41 AM1/7/10
to testng...@googlegroups.com
This is not an error, you can just ignore it.

-- 
Cedric
Cédric


Cédric Beust ♔

unread,
Jan 7, 2010, 11:23:04 AM1/7/10
to testng...@googlegroups.com
I'm not familiar at all with the NetBeans plug-in, sorry, but it looks like it doesn't support this feature...

-- 
Cedric
Cédric


Reply all
Reply to author
Forward
0 new messages