<test name="T1" preserve-order="true">
<classes>
<class name="com.mypackage.tests.Test1Class">
<methods>
<include name="TC_004"/>
<include name="TC_005"/>
</methods>
</class>
</classes>
</test>
<test name="T2" preserve-order="true">
<classes>
<class name="com.mypackage.tests.Test2Class">
<methods>
<include name="TC_001"/>
<include name="TC_002"/>
</methods>
</class>
</classes>
</test>
Maven POM.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<!-- System Property Variables to consume from Maven invocation -->
<systemPropertyVariables>
<browser>${browser}</browser>
<browserVersion>${browserVersion}</browserVersion>
</systemPropertyVariables>
<!-- TestNG xml Configuration -->
<suiteXmlFiles>
<suiteXmlFile>${suiteFile}</suiteXmlFile>
</suiteXmlFiles>
<!-- Project level Properties configuration -->
<properties>
<property> <!-- Block Default TestNG Listeners -->
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>testnames</name>
<value>${testCases}</value>
</property>
</properties>
<!-- Maven Run Configurations -->
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
Maven Profile will have the suiteXml value and the execution is invoked using: mvn test -P featureTests -DtestCases=T1,T2
What i am looking for is, if i invoke the execution using: mvn test -P featureTests the execution to happen with all tests in the testNG xml
But here it is failing with below: The test(s) <[]> cannot be found.
Srikanth,
The current implementation is such that once you provide testnames then a match is always done only against what was provided. That explains why you see that error, when you don’t provide any testnames to be executed.
But you still can get this done if you make use of a beanshell executor as your selector in your suite file.
The beanshell executor basically exposes the ITestNGMethod (the test method in the TestNG world) object to your selector. So you should be able to query its “test name” via its ITestContext object, cross check that with the testnames provided via the JVM argument and proceed further. So you could basically disable this filtering if the JVM argument was null (or) empty, which is what you mean by if no test names were provided, then run everything
For more information on working with beanshell, please refer to the following:
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/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--
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 https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
<test name="Feature Tests">
<method-selectors>
<method-selector>
<script language="beanshell">
<![CDATA[
String test=System.getProperty("testCase");
testngMethod.getMethodName().contains(test);
]]>
</script>
</method-selector>
</method-selectors>
<packages>
<package name="com.xxx.yyyy.abc"/>
</packages >
</test>
Thanks,
Srikanth M