need help in testng.xml file in parallel execution with jenkins

190 views
Skip to first unread message

joshua p

unread,
Sep 3, 2013, 1:23:40 AM9/3/13
to seleniu...@googlegroups.com
Hi All,
 I am facing a issue with testng.xml file..., In my testng.xml file in <suite>

<test name=1>
<groups> </groups>
<classes> </classes>
</test>

<test name=2>
<groups> </groups>
<classes> </classes>
</test>

<test name=3>
<groups> </groups>
<classes> </classes>
</test>

<test name=4>
<groups> </groups>
<classes> </classes>
</test>

</suite>


Now the issue is i want to call tests with name 1,2 for once or 2,3 or another time and so on... so how to call these tests at run time in jenkins.... insted of calling this testng.xml file can i call these different <tests> at run time... I hope u r clear with my question.. I dont want to call the compelete testng.xml file but I want to call 1 <test> at a time or 2 <test> at another time depending upon the requirement....
Is their any probability.

Thanks.
Regards
Joshua

Krishnan Mahadevan

unread,
Sep 3, 2013, 7:36:04 AM9/3/13
to Selenium Users
Yes you can.

Here's how you do it.

To begin with you can add a method-selector as shown below to every test of yours.


<method-selectors>
<method-selector>
<script language="beanshell">
<![CDATA[
testName = testngMethod.getXmlTest().getName();
print ("testname = " + testName);
return testName.equals(System.getProperty("whichTestToRun"));
]]>
</script>
</method-selector>
</method-selectors>

Now you can run your suite using the VM arg -DwhichTestToRun=<yourTestNameGoesHere>

For more information refer to this post of mine : http://rationaleemotions.wordpress.com/2013/08/21/beanshell-and-testng/


Cedric states that method-selector can be included in suite or test tags.[ Refer this thread : https://groups.google.com/forum/#!topic/testng-users/WhqhCg1a9TQ ]

I havent been able to get it to work on the suite level, because apart from the method selector being completely ignored, I also see this error 

org.testng.TestNGException: 
Invalid Method Selector:  found neither class name nor language
at org.testng.xml.XmlMethodSelector.toXml(XmlMethodSelector.java:111)
at org.testng.xml.XmlTest.toXml(XmlTest.java:487)
at org.testng.xml.XmlSuite.toXml(XmlSuite.java:516)
at org.testng.reporters.jq.TestNgXmlPanel.getContent(TestNgXmlPanel.java:28)
at org.testng.reporters.jq.BaseMultiSuitePanel.generate(BaseMultiSuitePanel.java:24)
at org.testng.reporters.jq.Main.generateReport(Main.java:63)
at org.testng.TestNG.generateReports(TestNG.java:1115)
at org.testng.TestNG.run(TestNG.java:1074)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)


I presume there's a bug somewhere which is causing this, but I havent dug in more on that aspect yet !






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/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f31d15f0-bb94-46a6-b8af-9a1bbaf06612%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Krishnan Mahadevan

unread,
Sep 3, 2013, 7:37:03 AM9/3/13
to Selenium Users
I just now realized you posted a TestNG question on a Selenium forum.

Please help keep this forum relevant by posting questions that are ONLY related to Selenium/WebDriver.

For TestNG queries, please post on the testng-users google forum !

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/


Message has been deleted

joshua p

unread,
Sep 4, 2013, 10:22:26 AM9/4/13
to seleniu...@googlegroups.com
Hi Krishnan,
                       Is their any workaround for this issue.. so that only few tests tags will get executed during runtime..

Krishnan Mahadevan

unread,
Sep 4, 2013, 10:34:36 AM9/4/13
to Selenium Users
I believe I already gave the information that I had. The only way to get this to work right now is to add the method-selector section to each of your <test> tags.

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/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages