How to use DataProvider with @BeforeTest

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use DataProvider with @BeforeTest

valmondw
I set a database row in my beforeTest() method as follows.
@BeforeTest
public void beforeTest() {
   setDataRow("DATABASE_ROW", 5);
}
 
I would like to parameterize the value 5 because I want a different database row to
be set for each iteration

Is there a way in TestNg that I can pass a value from a Dataprovider method to a method
annotated with
@BeforeTest
@BeforeClass
@BeforeMethod

For example doing something like this:
@BeforeTest(dataProvider="dataRows")
public void beforeTest(int row) {
    setDataRow("DATABASE_ROW", row);
}  
 
 
@DataProvider(name = "dataRows")
public Object[][] getData(){
  Object[][] data = new Object[2][1];
  data[0][0]=5;
  data[1][0]=4;
  return data;
}
 
Thanks
Vasty

 

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use DataProvider with @BeforeTest

Bryan
Hi, It's a good question!

I'd like to make sure I understand what you are thinking about. So, is it like this:

You have several tests, and you have a fixture for those tests using @BeforeTest and @AfterTest for setup and teardown, respectively.

You'd like to run this whole thing once for every datapoint that the dataprovider provides.


Is this correct?






On Mon, Mar 24, 2014 at 1:07 PM, Vasty Jay <[hidden email]> wrote:
I set a database row in my beforeTest() method as follows.
@BeforeTest
public void beforeTest() {
   setDataRow("DATABASE_ROW", 5);
}
 
I would like to parameterize the value 5 because I want a different database row to
be set for each iteration

Is there a way in TestNg that I can pass a value from a Dataprovider method to a method
annotated with
@BeforeTest
@BeforeClass
@BeforeMethod

For example doing something like this:
@BeforeTest(dataProvider="dataRows")
public void beforeTest(int row) {
    setDataRow("DATABASE_ROW", row);
}  
 
 
@DataProvider(name = "dataRows")
public Object[][] getData(){
  Object[][] data = new Object[2][1];
  data[0][0]=5;
  data[1][0]=4;
  return data;
}
 
Thanks
Vasty

 

--
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 http://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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use DataProvider with @BeforeTest

valmondw

Hi Bryan,
Thanks for your quick response.
Yes that's exactly what I want to do.

On Mar 24, 2014 8:03 PM, "Bryan" <[hidden email]> wrote:
Hi, It's a good question!

I'd like to make sure I understand what you are thinking about. So, is it like this:

You have several tests, and you have a fixture for those tests using @BeforeTest and @AfterTest for setup and teardown, respectively.

You'd like to run this whole thing once for every datapoint that the dataprovider provides.


Is this correct?






On Mon, Mar 24, 2014 at 1:07 PM, Vasty Jay <[hidden email]> wrote:
I set a database row in my beforeTest() method as follows.
@BeforeTest
public void beforeTest() {
   setDataRow("DATABASE_ROW", 5);
}
 
I would like to parameterize the value 5 because I want a different database row to
be set for each iteration

Is there a way in TestNg that I can pass a value from a Dataprovider method to a method
annotated with
@BeforeTest
@BeforeClass
@BeforeMethod

For example doing something like this:
@BeforeTest(dataProvider="dataRows")
public void beforeTest(int row) {
    setDataRow("DATABASE_ROW", row);
}  
 
 
@DataProvider(name = "dataRows")
public Object[][] getData(){
  Object[][] data = new Object[2][1];
  data[0][0]=5;
  data[1][0]=4;
  return data;
}
 
Thanks
Vasty

 

--
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 http://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 a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use DataProvider with @BeforeTest

Krishnan Mahadevan
Have you considered using a @Factory + @DataProvider to get this done ?

Your DataProvider would basically provide values that your factory method requires to create TestClass instances. Within your TestClass instance you can then have a @BeforeClass or a @BeforeMethod work with the values received while instantiation and proceed. Would that work ?


iSent. iPhone. iReget. iThumbs.iTypos!

On 25-Mar-2014, at 2:18, Vasty Jay <[hidden email]> wrote:

Hi Bryan,
Thanks for your quick response.
Yes that's exactly what I want to do.

On Mar 24, 2014 8:03 PM, "Bryan" <[hidden email]> wrote:
Hi, It's a good question!

I'd like to make sure I understand what you are thinking about. So, is it like this:

You have several tests, and you have a fixture for those tests using @BeforeTest and @AfterTest for setup and teardown, respectively.

You'd like to run this whole thing once for every datapoint that the dataprovider provides.


Is this correct?






On Mon, Mar 24, 2014 at 1:07 PM, Vasty Jay <[hidden email]> wrote:
I set a database row in my beforeTest() method as follows.
@BeforeTest
public void beforeTest() {
   setDataRow("DATABASE_ROW", 5);
}
 
I would like to parameterize the value 5 because I want a different database row to
be set for each iteration

Is there a way in TestNg that I can pass a value from a Dataprovider method to a method
annotated with
@BeforeTest
@BeforeClass
@BeforeMethod

For example doing something like this:
@BeforeTest(dataProvider="dataRows")
public void beforeTest(int row) {
    setDataRow("DATABASE_ROW", row);
}  
 
 
@DataProvider(name = "dataRows")
public Object[][] getData(){
  Object[][] data = new Object[2][1];
  data[0][0]=5;
  data[1][0]=4;
  return data;
}
 
Thanks
Vasty

 

--
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 http://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 a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://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 http://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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use DataProvider with @BeforeTest

valmondw
Hi Krishnan,
Thanks for your suggestion, I just need to figure out how to combine the two annotations together to achieve the desired result.
An example will be great.
 
Thanks

On Tuesday, March 25, 2014 1:20:26 AM UTC, Krishnan wrote:
Have you considered using a @Factory + @DataProvider to get this done ?

Your DataProvider would basically provide values that your factory method requires to create TestClass instances. Within your TestClass instance you can then have a @BeforeClass or a @BeforeMethod work with the values received while instantiation and proceed. Would that work ?


iSent. iPhone. iReget. iThumbs.iTypos!

On 25-Mar-2014, at 2:18, Vasty Jay <<a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="630" gdf-obfuscated-mailto="juabA7OjAKkJ">valm...@...> wrote:

Hi Bryan,
Thanks for your quick response.
Yes that's exactly what I want to do.

On Mar 24, 2014 8:03 PM, "Bryan" <<a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="639" gdf-obfuscated-mailto="juabA7OjAKkJ">br...@...> wrote:
Hi, It's a good question!

I'd like to make sure I understand what you are thinking about. So, is it like this:

You have several tests, and you have a fixture for those tests using @BeforeTest and @AfterTest for setup and teardown, respectively.

You'd like to run this whole thing once for every datapoint that the dataprovider provides.


Is this correct?






On Mon, Mar 24, 2014 at 1:07 PM, Vasty Jay <<a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="665" gdf-obfuscated-mailto="juabA7OjAKkJ">valm...@...> wrote:
I set a database row in my beforeTest() method as follows.
@BeforeTest
public void beforeTest() {
   setDataRow("DATABASE_ROW", 5);
}
 
I would like to parameterize the value 5 because I want a different database row to
be set for each iteration

Is there a way in TestNg that I can pass a value from a Dataprovider method to a method
annotated with
@BeforeTest
@BeforeClass
@BeforeMethod

For example doing something like this:
@BeforeTest(dataProvider="dataRows")
public void beforeTest(int row) {
    setDataRow("DATABASE_ROW", row);
}  
 
 
@DataProvider(name = "dataRows")
public Object[][] getData(){
  Object[][] data = new Object[2][1];
  data[0][0]=5;
  data[1][0]=4;
  return data;
}
 
Thanks
Vasty

 

--
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 onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="711" gdf-obfuscated-mailto="juabA7OjAKkJ">testng-users...@googlegroups.com.
To post to this group, send email to <a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="714" gdf-obfuscated-mailto="juabA7OjAKkJ">testng...@....
Visit this group at <a onmousedown="this.href='http://groups.google.com/group/testng-users';return true;" onclick="this.href='http://groups.google.com/group/testng-users';return true;" href="http://groups.google.com/group/testng-users" target="_blank" abp="716">http://groups.google.com/group/testng-users.
For more options, visit <a onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" href="https://groups.google.com/d/optout" target="_blank" abp="719">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit <a onmousedown="this.href='https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe';return true;" onclick="this.href='https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe';return true;" href="https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe" target="_blank" abp="726">https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to <a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="730" gdf-obfuscated-mailto="juabA7OjAKkJ">testng-users...@googlegroups.com.
To post to this group, send email to <a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="733" gdf-obfuscated-mailto="juabA7OjAKkJ">testng...@....
Visit this group at <a onmousedown="this.href='http://groups.google.com/group/testng-users';return true;" onclick="this.href='http://groups.google.com/group/testng-users';return true;" href="http://groups.google.com/group/testng-users" target="_blank" abp="735">http://groups.google.com/group/testng-users.
For more options, visit <a onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" href="https://groups.google.com/d/optout" target="_blank" abp="738">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 <a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="744" gdf-obfuscated-mailto="juabA7OjAKkJ">testng-users...@googlegroups.com.
To post to this group, send email to <a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="747" gdf-obfuscated-mailto="juabA7OjAKkJ">testng...@....
Visit this group at <a onmousedown="this.href='http://groups.google.com/group/testng-users';return true;" onclick="this.href='http://groups.google.com/group/testng-users';return true;" href="http://groups.google.com/group/testng-users" target="_blank" abp="749">http://groups.google.com/group/testng-users.
For more options, visit <a onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" href="https://groups.google.com/d/optout" target="_blank" abp="752">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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use DataProvider with @BeforeTest

Krishnan Mahadevan
Please refer to the scenario 3 section of my blog post : http://rationaleemotions.wordpress.com/2013/07/31/pretty-printing-with-testng/

You should see a sample there.

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 Tue, Mar 25, 2014 at 5:23 PM, Vasty Jay <[hidden email]> wrote:
Hi Krishnan,
Thanks for your suggestion, I just need to figure out how to combine the two annotations together to achieve the desired result.
An example will be great.
 
Thanks

On Tuesday, March 25, 2014 1:20:26 AM UTC, Krishnan wrote:
Have you considered using a @Factory + @DataProvider to get this done ?

Your DataProvider would basically provide values that your factory method requires to create TestClass instances. Within your TestClass instance you can then have a @BeforeClass or a @BeforeMethod work with the values received while instantiation and proceed. Would that work ?


iSent. iPhone. iReget. iThumbs.iTypos!

On 25-Mar-2014, at 2:18, Vasty Jay <[hidden email]> wrote:

Hi Bryan,
Thanks for your quick response.
Yes that's exactly what I want to do.

On Mar 24, 2014 8:03 PM, "Bryan" <[hidden email]> wrote:
Hi, It's a good question!

I'd like to make sure I understand what you are thinking about. So, is it like this:

You have several tests, and you have a fixture for those tests using @BeforeTest and @AfterTest for setup and teardown, respectively.

You'd like to run this whole thing once for every datapoint that the dataprovider provides.


Is this correct?






On Mon, Mar 24, 2014 at 1:07 PM, Vasty Jay <[hidden email]> wrote:
I set a database row in my beforeTest() method as follows.
@BeforeTest
public void beforeTest() {
   setDataRow("DATABASE_ROW", 5);
}
 
I would like to parameterize the value 5 because I want a different database row to
be set for each iteration

Is there a way in TestNg that I can pass a value from a Dataprovider method to a method
annotated with
@BeforeTest
@BeforeClass
@BeforeMethod

For example doing something like this:
@BeforeTest(dataProvider="dataRows")
public void beforeTest(int row) {
    setDataRow("DATABASE_ROW", row);
}  
 
 
@DataProvider(name = "dataRows")
public Object[][] getData(){
  Object[][] data = new Object[2][1];
  data[0][0]=5;
  data[1][0]=4;
  return data;
}
 
Thanks
Vasty

 

--
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].

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].

--
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].

--
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 http://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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use DataProvider with @BeforeTest

valmondw
Thanks Krishnan

On Tuesday, March 25, 2014 11:56:59 AM UTC, Krishnan wrote:
Please refer to the scenario 3 section of my blog post : <a onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Frationaleemotions.wordpress.com%2F2013%2F07%2F31%2Fpretty-printing-with-testng%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNGItBWrwaEbg-_De8ubg-wyA4oIQA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Frationaleemotions.wordpress.com%2F2013%2F07%2F31%2Fpretty-printing-with-testng%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNGItBWrwaEbg-_De8ubg-wyA4oIQA';return true;" href="http://rationaleemotions.wordpress.com/2013/07/31/pretty-printing-with-testng/" target="_blank" abp="840">http://rationaleemotions.wordpress.com/2013/07/31/pretty-printing-with-testng/

You should see a sample there.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwakened-cognition.blogspot.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwakened-cognition.blogspot.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ';return true;" href="http://wakened-cognition.blogspot.com/" target="_blank" abp="854">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Frationaleemotions.wordpress.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Frationaleemotions.wordpress.com%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ';return true;" href="http://rationaleemotions.wordpress.com/" target="_blank" abp="857">http://rationaleemotions.wordpress.com/


On Tue, Mar 25, 2014 at 5:23 PM, Vasty Jay <<a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="863" gdf-obfuscated-mailto="1z8BsQKW16gJ">valm...@...> wrote:
Hi Krishnan,
Thanks for your suggestion, I just need to figure out how to combine the two annotations together to achieve the desired result.
An example will be great.
 
Thanks

On Tuesday, March 25, 2014 1:20:26 AM UTC, Krishnan wrote:
Have you considered using a @Factory + @DataProvider to get this done ?

Your DataProvider would basically provide values that your factory method requires to create TestClass instances. Within your TestClass instance you can then have a @BeforeClass or a @BeforeMethod work with the values received while instantiation and proceed. Would that work ?


iSent. iPhone. iReget. iThumbs.iTypos!

On 25-Mar-2014, at 2:18, Vasty Jay <[hidden email]> wrote:

Hi Bryan,
Thanks for your quick response.
Yes that's exactly what I want to do.

On Mar 24, 2014 8:03 PM, "Bryan" <[hidden email]> wrote:
Hi, It's a good question!

I'd like to make sure I understand what you are thinking about. So, is it like this:

You have several tests, and you have a fixture for those tests using @BeforeTest and @AfterTest for setup and teardown, respectively.

You'd like to run this whole thing once for every datapoint that the dataprovider provides.


Is this correct?






On Mon, Mar 24, 2014 at 1:07 PM, Vasty Jay <[hidden email]> wrote:
I set a database row in my beforeTest() method as follows.
@BeforeTest
public void beforeTest() {
   setDataRow("DATABASE_ROW", 5);
}
 
I would like to parameterize the value 5 because I want a different database row to
be set for each iteration

Is there a way in TestNg that I can pass a value from a Dataprovider method to a method
annotated with
@BeforeTest
@BeforeClass
@BeforeMethod

For example doing something like this:
@BeforeTest(dataProvider="dataRows")
public void beforeTest(int row) {
    setDataRow("DATABASE_ROW", row);
}  
 
 
@DataProvider(name = "dataRows")
public Object[][] getData(){
  Object[][] data = new Object[2][1];
  data[0][0]=5;
  data[1][0]=4;
  return data;
}
 
Thanks
Vasty

 

--
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 onmousedown="this.href='http://groups.google.com/group/testng-users';return true;" onclick="this.href='http://groups.google.com/group/testng-users';return true;" href="http://groups.google.com/group/testng-users" target="_blank" abp="986">http://groups.google.com/group/testng-users.
For more options, visit <a onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" href="https://groups.google.com/d/optout" target="_blank" abp="990">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit <a onmousedown="this.href='https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe';return true;" onclick="this.href='https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe';return true;" href="https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe" target="_blank" abp="999">https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].

Visit this group at <a onmousedown="this.href='http://groups.google.com/group/testng-users';return true;" onclick="this.href='http://groups.google.com/group/testng-users';return true;" href="http://groups.google.com/group/testng-users" target="_blank" abp="1012">http://groups.google.com/group/testng-users.
For more options, visit <a onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" href="https://groups.google.com/d/optout" target="_blank" abp="1016">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 testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].

Visit this group at <a onmousedown="this.href='http://groups.google.com/group/testng-users';return true;" onclick="this.href='http://groups.google.com/group/testng-users';return true;" href="http://groups.google.com/group/testng-users" target="_blank" abp="1031">http://groups.google.com/group/testng-users.
For more options, visit <a onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" href="https://groups.google.com/d/optout" target="_blank" abp="1035">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 <a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="1044" gdf-obfuscated-mailto="1z8BsQKW16gJ">testng-users...@googlegroups.com.
To post to this group, send email to <a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" abp="1047" gdf-obfuscated-mailto="1z8BsQKW16gJ">testng...@....
Visit this group at <a onmousedown="this.href='http://groups.google.com/group/testng-users';return true;" onclick="this.href='http://groups.google.com/group/testng-users';return true;" href="http://groups.google.com/group/testng-users" target="_blank" abp="1049">http://groups.google.com/group/testng-users.
For more options, visit <a onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" href="https://groups.google.com/d/optout" target="_blank" abp="1052">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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to use DataProvider with @BeforeTest

jennifer.huang
In reply to this post by Krishnan Mahadevan
Hello ,I have the same requirement, 
I can't open this post: http://rationaleemotions.wordpress.com/2013/07/31/pretty-printing-with-testng/
could you help give an example.

On Tuesday, March 25, 2014 at 7:56:59 PM UTC+8, Krishnan Mahadevan wrote:
Please refer to the scenario 3 section of my blog post : <a href="http://www.google.com/url?q=http%3A%2F%2Frationaleemotions.wordpress.com%2F2013%2F07%2F31%2Fpretty-printing-with-testng%2F&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNGItBWrwaEbg-_De8ubg-wyA4oIQA" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F2013%2F07%2F31%2Fpretty-printing-with-testng%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGItBWrwaEbg-_De8ubg-wyA4oIQA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F2013%2F07%2F31%2Fpretty-printing-with-testng%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGItBWrwaEbg-_De8ubg-wyA4oIQA&#39;;return true;">http://rationaleemotions.wordpress.com/2013/07/31/pretty-printing-with-testng/

You should see a sample there.

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 Tue, Mar 25, 2014 at 5:23 PM, Vasty Jay <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="1z8BsQKW16gJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">valm...@...> wrote:
Hi Krishnan,
Thanks for your suggestion, I just need to figure out how to combine the two annotations together to achieve the desired result.
An example will be great.
 
Thanks

On Tuesday, March 25, 2014 1:20:26 AM UTC, Krishnan wrote:
Have you considered using a @Factory + @DataProvider to get this done ?

Your DataProvider would basically provide values that your factory method requires to create TestClass instances. Within your TestClass instance you can then have a @BeforeClass or a @BeforeMethod work with the values received while instantiation and proceed. Would that work ?


iSent. iPhone. iReget. iThumbs.iTypos!

On 25-Mar-2014, at 2:18, Vasty Jay <[hidden email]> wrote:

Hi Bryan,
Thanks for your quick response.
Yes that's exactly what I want to do.

On Mar 24, 2014 8:03 PM, "Bryan" <[hidden email]> wrote:
Hi, It's a good question!

I'd like to make sure I understand what you are thinking about. So, is it like this:

You have several tests, and you have a fixture for those tests using @BeforeTest and @AfterTest for setup and teardown, respectively.

You'd like to run this whole thing once for every datapoint that the dataprovider provides.


Is this correct?






On Mon, Mar 24, 2014 at 1:07 PM, Vasty Jay <[hidden email]> wrote:
I set a database row in my beforeTest() method as follows.
@BeforeTest
public void beforeTest() {
   setDataRow("DATABASE_ROW", 5);
}
 
I would like to parameterize the value 5 because I want a different database row to
be set for each iteration

Is there a way in TestNg that I can pass a value from a Dataprovider method to a method
annotated with
@BeforeTest
@BeforeClass
@BeforeMethod

For example doing something like this:
@BeforeTest(dataProvider="dataRows")
public void beforeTest(int row) {
    setDataRow("DATABASE_ROW", row);
}  
 
 
@DataProvider(name = "dataRows")
public Object[][] getData(){
  Object[][] data = new Object[2][1];
  data[0][0]=5;
  data[1][0]=4;
  return data;
}
 
Thanks
Vasty

 

--
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="http://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;">http://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 a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe&#39;;return true;">https://groups.google.com/d/topic/testng-users/jyaaHRCQu2s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].

Visit this group at <a href="http://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;">http://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 testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].

Visit this group at <a href="http://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;">http://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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="1z8BsQKW16gJ" 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="1z8BsQKW16gJ" 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="http://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/testng-users&#39;;return true;">http://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.