@DataProvider annotation for a Test Suite

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

@DataProvider annotation for a Test Suite

Harihara Vinayakaram

Hi
  I am sorry if this question has been asked and answered before. From
what I understand in the documentation I can define a testng.xml to
have a test suite and then run the suite with a set of parameters.
That is I want all tests of a suite to run and then run again for a
different set of parameters

 Is there a way I can do this with a @DataProvider annotation

Thanks
Regards
Hari

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

Reply | Threaded
Open this post in threaded view
|

Re: @DataProvider annotation for a Test Suite

Cédric Beust ♔

Parameters in testng.xml are useful for simple values (integers,
strings, etc...).

If you want to do something more complex, @DataProvider is a more
flexible way to provide parameters to your tests.

Feel free to give more details on what you're trying to do and I can
give you more specific explanations.

--
Cedric



On 3/17/09, [hidden email] <[hidden email]> wrote:

>
> Hi
>   I am sorry if this question has been asked and answered before. From
> what I understand in the documentation I can define a testng.xml to
> have a test suite and then run the suite with a set of parameters.
> That is I want all tests of a suite to run and then run again for a
> different set of parameters
>
>  Is there a way I can do this with a @DataProvider annotation
>
> Thanks
> Regards
> Hari
>
> >
>


--
Cédric

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

Reply | Threaded
Open this post in threaded view
|

Re: @DataProvider annotation for a Test Suite

Harihara Vinayakaram
Hi
  This is what I have tried . I have a set of parameters in a xml file. I have a class which reads this xml file and converts them to a java bean  These are typically parameters for a user.
  So I have somthing like

@Test (dataProvider="myDataProvider")
public void test01(TestUserConfig testUserConfig) {
}

which works perfectly
I now added 2 more methods
test02 and test03

@Test(dataProvider="myDataProvider", dependsOnMethods="test01")
public void test02 (...) {
}

The order of execution now becomes
     test01 is executed for all scenario1 , scenario2
    and then test02 is executed for scenario1 , scenario2

I want a way to
    execute test01 and test02   for scenario1
    exectute test01 and test02 for scenario2
and so on

Let me know if this can be acheived .
I tried annotating the class with the @Test (dataProcier=" ") but that did not seem to help

Regards
Hari

2009/3/17 Cédric Beust ♔ <[hidden email]>

Parameters in testng.xml are useful for simple values (integers,
strings, etc...).

If you want to do something more complex, @DataProvider is a more
flexible way to provide parameters to your tests.

Feel free to give more details on what you're trying to do and I can
give you more specific explanations.

--
Cedric



On 3/17/09, [hidden email] <[hidden email]> wrote:
>
> Hi
>   I am sorry if this question has been asked and answered before. From
> what I understand in the documentation I can define a testng.xml to
> have a test suite and then run the suite with a set of parameters.
> That is I want all tests of a suite to run and then run again for a
> different set of parameters
>
>  Is there a way I can do this with a @DataProvider annotation
>
> Thanks
> Regards
> Hari
>
> >
>


--
Cédric




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

Reply | Threaded
Open this post in threaded view
|

Re: @DataProvider annotation for a Test Suite

krishnan.1000
Currently you have to have two tests having the same data provider. Currently, i don' t think you can have comma separated data providers references although it will be nice to have.

On Tue, Mar 17, 2009 at 6:16 PM, Harihara Vinayakaram <[hidden email]> wrote:
Hi
  This is what I have tried . I have a set of parameters in a xml file. I have a class which reads this xml file and converts them to a java bean  These are typically parameters for a user.
  So I have somthing like

@Test (dataProvider="myDataProvider")
public void test01(TestUserConfig testUserConfig) {
}

which works perfectly
I now added 2 more methods
test02 and test03

@Test(dataProvider="myDataProvider", dependsOnMethods="test01")
public void test02 (...) {
}

The order of execution now becomes
     test01 is executed for all scenario1 , scenario2
    and then test02 is executed for scenario1 , scenario2

I want a way to
    execute test01 and test02   for scenario1
    exectute test01 and test02 for scenario2
and so on

Let me know if this can be acheived .
I tried annotating the class with the @Test (dataProcier=" ") but that did not seem to help

Regards
Hari

2009/3/17 Cédric Beust ♔ <[hidden email]>


Parameters in testng.xml are useful for simple values (integers,
strings, etc...).

If you want to do something more complex, @DataProvider is a more
flexible way to provide parameters to your tests.

Feel free to give more details on what you're trying to do and I can
give you more specific explanations.

--
Cedric



On 3/17/09, [hidden email] <[hidden email]> wrote:
>
> Hi
>   I am sorry if this question has been asked and answered before. From
> what I understand in the documentation I can define a testng.xml to
> have a test suite and then run the suite with a set of parameters.
> That is I want all tests of a suite to run and then run again for a
> different set of parameters
>
>  Is there a way I can do this with a @DataProvider annotation
>
> Thanks
> Regards
> Hari
>
> >
>


--
Cédric







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

Reply | Threaded
Open this post in threaded view
|

Re: @DataProvider annotation for a Test Suite

Cédric Beust ♔


On Wed, Mar 18, 2009 at 10:19 AM, Karthik Krishnan <[hidden email]> wrote:
Currently, i don' t think you can have comma separated data providers references although it will be nice to have.

The reason for this is simple:  if you need data coming from two different data providers, just create a third method that combines the output of the other two data providers and use that third data provider...

--
Cédric



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

Reply | Threaded
Open this post in threaded view
|

Re: @DataProvider annotation for a Test Suite

Harihara Vinayakaram
In reply to this post by krishnan.1000
Hi
   I have 1 dataProvider only which I am calling for 2 tests. The , separator was for a dependsOnmethod

Regards
Hari

On Wed, Mar 18, 2009 at 10:49 PM, Karthik Krishnan <[hidden email]> wrote:
Currently you have to have two tests having the same data provider. Currently, i don' t think you can have comma separated data providers references although it will be nice to have.


On Tue, Mar 17, 2009 at 6:16 PM, Harihara Vinayakaram <[hidden email]> wrote:
Hi
  This is what I have tried . I have a set of parameters in a xml file. I have a class which reads this xml file and converts them to a java bean  These are typically parameters for a user.
  So I have somthing like

@Test (dataProvider="myDataProvider")
public void test01(TestUserConfig testUserConfig) {
}

which works perfectly
I now added 2 more methods
test02 and test03

@Test(dataProvider="myDataProvider", dependsOnMethods="test01")
public void test02 (...) {
}

The order of execution now becomes
     test01 is executed for all scenario1 , scenario2
    and then test02 is executed for scenario1 , scenario2

I want a way to
    execute test01 and test02   for scenario1
    exectute test01 and test02 for scenario2
and so on

Let me know if this can be acheived .
I tried annotating the class with the @Test (dataProcier=" ") but that did not seem to help

Regards
Hari

2009/3/17 Cédric Beust ♔ <[hidden email]>


Parameters in testng.xml are useful for simple values (integers,
strings, etc...).

If you want to do something more complex, @DataProvider is a more
flexible way to provide parameters to your tests.

Feel free to give more details on what you're trying to do and I can
give you more specific explanations.

--
Cedric



On 3/17/09, [hidden email] <[hidden email]> wrote:
>
> Hi
>   I am sorry if this question has been asked and answered before. From
> what I understand in the documentation I can define a testng.xml to
> have a test suite and then run the suite with a set of parameters.
> That is I want all tests of a suite to run and then run again for a
> different set of parameters
>
>  Is there a way I can do this with a @DataProvider annotation
>
> Thanks
> Regards
> Hari
>
> >
>


--
Cédric










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

Reply | Threaded
Open this post in threaded view
|

Re: @DataProvider annotation for a Test Suite

desolat-2
In reply to this post by Cédric Beust ♔

2009/3/18 Cédric Beust ♔ <[hidden email]>:
>
> The reason for this is simple:  if you need data coming from two different
> data providers, just create a third method that combines the output of the
> other two data providers and use that third data provider...

Could you give a code example for this please?

Thx, Chris

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

Reply | Threaded
Open this post in threaded view
|

Re: @DataProvider annotation for a Test Suite

Cédric Beust ♔


On 3/23/09, Christoph Jaehnigen <[hidden email]> wrote:

2009/3/18 Cédric Beust ♔ <[hidden email]>:

>
> The reason for this is simple:  if you need data coming from two different
> data providers, just create a third method that combines the output of the
> other two data providers and use that third data provider...


Could you give a code example for this please?

If you want to combine the output of two data providers:

@DataProvider
public Object[][] dp1() { ... }

@DataProvider
public Object[][] dp2() { ... }

You just create a third one:

@DataProvider
public Object[][] dp3() {
  Object[][] result1 = dp1();
  Object[[][] result2 = dp2();
  return /* the sum of result1 and result2 */
}

--
Cedric

 

Thx, Chris



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

Reply | Threaded
Open this post in threaded view
|

Re: @DataProvider annotation for a Test Suite

Harihara Vinayakaram
In reply to this post by Harihara Vinayakaram

Hi
   I figured out the answer . Use @Factory instead of @DataProvider .
This solved the problem of running all methods in a class with one set
of parameters and then again with another set of parameters

Thanks
Regards
Hari

On Mar 17, 7:14 pm, "[hidden email]" <[hidden email]> wrote:

> Hi
>   I am sorry if this question has been asked and answered before. From
> what I understand in the documentation I can define a testng.xml to
> have a test suite and then run the suite with a set of parameters.
> That is I want all tests of a suite to run and then run again for a
> different set of parameters
>
>  Is there a way I can do this with a @DataProvider annotation
>
> Thanks
> Regards
> Hari
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: @DataProvider annotation for a Test Suite

Bhargav
Hi
I am using the factory to run a set of tests in my test class. Problem is Its not executing the tests one set after other. But its executing in parallael. My first test method is run for the first param and then new browser opens and the first test is run again. So on it repeats the first test for all params and then goes to the second test. I want it to execute all tests for first set pf params and then move to the second set of params. Any suggestions? I have tried setting parallel ="false" in my testNG suite xml. That didnt work. I have used dependsOnmethods. Could that be a reason?

On Sunday, March 29, 2009 11:09:09 AM UTC+5:30, Harihara Vinayakaram wrote:
Hi
   I figured out the answer . Use @Factory instead of @DataProvider .
This solved the problem of running all methods in a class with one set
of parameters and then again with another set of parameters

Thanks
Regards
Hari

On Mar 17, 7:14 pm, "[hidden email]" <[hidden email]> wrote:

> Hi
>   I am sorry if this question has been asked and answered before. From
> what I understand in the documentation I can define a testng.xml to
> have a test suite and then run the suite with a set of parameters.
> That is I want all tests of a suite to run and then run again for a
> different set of parameters
>
>  Is there a way I can do this with a @DataProvider annotation
>
> Thanks
> Regards
> Hari

--
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/groups/opt_out.