Issue with multiple values for the same parameter for a given @Test method

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Issue with multiple values for the same parameter for a given @Test method

akshay.maldhure
Below is the snippet from my testng.xml file:

<test name="Some Test"> <classes> <class name="package.TestClass"> <methods> <include name="someTest"> <parameter name="language" value="en" /> </include> <include name="someTest"> <parameter name="language" value="gu" /> </include> <include name="someTest"> <parameter name="language" value="hi" /> </include> <include name="someTest"> <parameter name="language" value="mr" /> </include> </methods> </class> </classes> <test/>

The issue is that someTest gets executed only for <parameter name="language" value="en" /> and it is not run at all for other values of the parameter "language".


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issue with multiple values for the same parameter for a given @Test method

Krishnan Mahadevan
Which version of TestNG are you on ? 
Do you have a sample that you can share with us so that we can see what is going on ?

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/

On Thu, Jun 29, 2017 at 11:34 AM, <[hidden email]> wrote:
Below is the snippet from my testng.xml file:

<test name="Some Test"> <classes> <class name="package.TestClass"> <methods> <include name="someTest"> <parameter name="language" value="en" /> </include> <include name="someTest"> <parameter name="language" value="gu" /> </include> <include name="someTest"> <parameter name="language" value="hi" /> </include> <include name="someTest"> <parameter name="language" value="mr" /> </include> </methods> </class> </classes> <test/>

The issue is that someTest gets executed only for <parameter name="language" value="en" /> and it is not run at all for other values of the parameter "language".


--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issue with multiple values for the same parameter for a given @Test method

akshay.maldhure
Thanks Krishnan for your response. I'm on TestNG 6.8 version.

Below is the code sample corresponding to the testng.xml file contents I shared earlier in this thread.

@Test
@Parameters({"language"})
public void someTest(String language) {
 
System.out.println("Language is: "+language);
}


Output: en

I was expecting the output to be something like:
en
gu
hi
mr


On Thursday, June 29, 2017 at 11:45:51 AM UTC+5:30, Krishnan wrote:
Which version of TestNG are you on ? 
Do you have a sample that you can share with us so that we can see what is going on ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Thu, Jun 29, 2017 at 11:34 AM, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="z_0QCXUODgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">akshay....@...> wrote:
Below is the snippet from my testng.xml file:

<test name="Some Test"> <classes> <class name="package.TestClass"> <methods> <include name="someTest"> <parameter name="language" value="en" /> </include> <include name="someTest"> <parameter name="language" value="gu" /> </include> <include name="someTest"> <parameter name="language" value="hi" /> </include> <include name="someTest"> <parameter name="language" value="mr" /> </include> </methods> </class> </classes> <test/>

The issue is that someTest gets executed only for <parameter name="language" value="en" /> and it is not run at all for other values of the parameter "language".


--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="z_0QCXUODgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="z_0QCXUODgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issue with multiple values for the same parameter for a given @Test method

akshay.maldhure
Solved the issue with the DataProvider approach.

 @DataProvider(name="languageProvider")
 
public static Object[][] getLanguages(ITestContext context) {
 
return new Object[][] {
     
{"en"},
     
{"hi"},
     
{"mr"},
     
{"gu"},
   
};
 
}

 @Test(dataProvider = "languageProvider")
 
public void someTest(String language) {
     
System.out.println("Language is: "+language);
 
}

Output:
Language is: en
Language is: hi
Language is: mr
Language is: gu

On Thursday, June 29, 2017 at 11:49:20 AM UTC+5:30, [hidden email] wrote:
Thanks Krishnan for your response. I'm on TestNG 6.8 version.

Below is the code sample corresponding to the testng.xml file contents I shared earlier in this thread.

@Test
@Parameters({"language"})
public void someTest(String language) {
 
System.out.println("Language is: "+language);
}


Output: en

I was expecting the output to be something like:
en
gu
hi
mr


On Thursday, June 29, 2017 at 11:45:51 AM UTC+5:30, Krishnan wrote:
Which version of TestNG are you on ? 
Do you have a sample that you can share with us so that we can see what is going on ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Thu, Jun 29, 2017 at 11:34 AM, <[hidden email]> wrote:
Below is the snippet from my testng.xml file:

<test name="Some Test"> <classes> <class name="package.TestClass"> <methods> <include name="someTest"> <parameter name="language" value="en" /> </include> <include name="someTest"> <parameter name="language" value="gu" /> </include> <include name="someTest"> <parameter name="language" value="hi" /> </include> <include name="someTest"> <parameter name="language" value="mr" /> </include> </methods> </class> </classes> <test/>

The issue is that someTest gets executed only for <parameter name="language" value="en" /> and it is not run at all for other values of the parameter "language".


--
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 [hidden email].
Visit this group at <a href="https://groups.google.com/group/testng-users" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issue with multiple values for the same parameter for a given @Test method

wenijinew
Hi,

Here is my analysis about the root cause:

TestNG collect all test methods with @Test annotation and then decide which methods should be executed based on the configuration in Suite XML file. If the method is in include list (and not in exclude list), then it will be executed. So, the biggest test methods collection to run is the methods with @Test annotation.

You are welcome to correct me if I am wrong.

Bruce Wen

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issue with multiple values for the same parameter for a given @Test method

Krishnan Mahadevan

Bruce,

 

I didn’t quite understand how that explanation fits into the OP’s problem which is basically that

when one wants to execute the same @Test method with different values, then TestNG ends up executing the method only with the last value

 

 

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/

 

From: <[hidden email]> on behalf of wenijinew <[hidden email]>
Reply-To: <[hidden email]>
Date: Sunday, July 2, 2017 at 1:19 PM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] Issue with multiple values for the same parameter for a given @Test method

 

Hi,

Here is my analysis about the root cause:

TestNG collect all test methods with @Test annotation and then decide which methods should be executed based on the configuration in Suite XML file. If the method is in include list (and not in exclude list), then it will be executed. So, the biggest test methods collection to run is the methods with @Test annotation.

You are welcome to correct me if I am wrong.

Bruce Wen

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Loading...