Use Factory for 2 DataProviders

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Use Factory for 2 DataProviders

Star
This post has NOT been accepted by the mailing list yet.
Hello,

I have 2 dataproviders:

@DataProvider(name = "myDataProvider1")
public static Object[][] myDataProvider1(){
         return new Object[][] {
                  new Object[] {"One"},
                  new Object[] {"Two"}
         };
}

@DataProvider(name = "myDataProvider2")
public static Object[][] myDataProvider2(){
         return new Object[][] {
                  new Object[] {"Three"},
                  new Object[] {"Four"}
         };
}


In a new class, I have created a constructor as shown below:

@Factory(dataProvider = "myDataProvider1", dataProviderClass = DataProvider.class)
public ClassA(String number1) {
         System.out.println("Instance created for - " + number1);
         this.myString = number1;
}

This would create 2 instances of ClassA and executes @Test methods (not shown above) accordingly based on objects returned from myDataProvider1.

Now my question is how will I create 2 more instances of ClassA based on objects returned from myDataProvider2 ?


Is there a way I can mention 2 dataproviders in @Factory ?
Is there any other way, I can execute @Test methods for myDataProvider1 objects as well as for myDataProvider2 objects ?


Please let me know any other workaround.

Thank you