DataProvider combined with @BeforeSuite

431 views
Skip to first unread message

Richard Hansson

unread,
Sep 6, 2017, 3:22:30 PM9/6/17
to testng-dev
Hello.
I've built an appium test suite ( automation framework for native apps)  with the help of  testNG framework. 

My test suite structure is the following : a baseClass where I setup my server capabilities and emulator options, I then extend my baseClass in all my tests, the baseClass has a @BeforeSuite annotation so I only setup my server ONCE when I run my xml file to run all the tests. 

I now want to run my testSuite on multiple emulators, I thought the easiest way to do this is use testng Dataprovider like this :


@DataProvider
public static Object[][] credentials() {

   
return new Object[][]{{"7.1.1", "Pixel_XL_API_25"}, {"6.0.0", "Nexus_6_API_23"}};

}

But the problem is I can't use a dataprovider combined with @BeforeSuite. How do I workaround this? I know this is intended that DataProvider can only be comebined with @Test. 

Appreciate all help
Regards

⇜Krishnan Mahadevan⇝

unread,
Sep 6, 2017, 9:27:00 PM9/6/17
to testn...@googlegroups.com

Richard

@BeforeSuite is designed to run ONLY once per <suite>.

If you want it to be run multiple times then you would need to choose one of the other alternatives :
1. @BeforeTest - runs before every <test>
2. @BeforeClass - runs before any @Test method in a test class gets executed
3. @BeforeMethod - runs before a @Test method.


--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-dev+...@googlegroups.com.
To post to this group, send email to testn...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/d/optout.
--

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/

William Kilian

unread,
Sep 6, 2017, 9:34:38 PM9/6/17
to testn...@googlegroups.com
This discussion belongs on the user list, but this use case also sounds like it fits @Factory better than @DataProvider.

Thanks,

William Kilian
--
Sent from my phone
Reply all
Reply to author
Forward
0 new messages