I have a query regarding testng suite structure best practices (and
execution order I guess).
The objective I'm trying to achieve is the automated testing of
several expected results in approximately 150 pages (which are
accessed via clicking each link from one 'main' page). My current
setup uses Testng, Reportng, Ant and Selenium Java.
I have a testing java class with the following structure:
@BeforeClass
// Selenium set up using various @Parameters
@DataProvider
// Definitions of ~150 dataproviders used to drive my tests
// Function definitions for:
- Opening a link given a specified name
- Comparing table row results based on the given DataProvider's data
- Return to the 'main' page
@Test (groups = {"webSetUp"})
// The next few tests handle logging in and navigating to the 'main'
page containing all the ~150 links
* This next stage is where I have 150 sets of 3 @Tests:
// The very first test depends on the success of reaching the main
page
@Test (dependsOnMethods = {"webSetUpMainPage"},
groups="regressionTest")
// E.g name: Alpha. Purpose: Opens link from main page
@Test (dataProvider = "dp1", dependsOnMethods = {"Alpha"})
// E.g name: Bravo. Purpose: Checks rows for expected results
@Test (dependsOnMethods = {"Bravo"}, alwaysRun = true)
// E.g name: Charlie. Purpose: Return to the main page
// New test set
@Test (dependsOnMethods = {"Charlie"}, groups="functionalTest"}
ETC.
@AfterClass
// Logout test/methods etc.
This current structure is fine when I want to run the entire suite.
However I want to start excluding/including groups from the test
suite. The problem that arises however is that Test set #2 from the
example, relies on the 'return to main page' @Test of Test set #1 (so
I get a message saying obviously I can't rely on a method I'm
excluding... :] )
But if I don't use this dependsOnMethods tactic then the grouped
running of Tests Alpha, Bravo and Charlie (a 'test set' perhaps,
doesn't hold (they don't run consecutively). Thus, I hope I've made my
main problem clear!
Any comments are very much appreciated. I am by no means an
accomplished java programmer or Testng wizard, but the point of me
posting this is to climb towards that goal. :)
Thanks in advance,
Phill