I have issues in invoking the configuration methods in my test code.
Here is the pseudo code.
Class Test
{
@Parameters({"a","b","c"})
@BeforeSuite
public void setUp
{
//Set values read from the testng.xml file
}
@BeforeClass
public void createSession()
{
//Using the server connection parameters read in the setUp method
create a session
}
@BeforeGroup
public void runStartupTasksBeforeTest()
{
//Start and stop multiple servers.
//This method has to be called before methods are executed in each
group
}
@Test(groups= {"windowsTests"}, dataProvider="windows")
public void testRunWindowsTestsInSequence(TestData oData)
{
// The parameter for this method is passed by dataprovider
}
@Test(groups= {"windowsTests"}, threadPoolSize = 5, invocationCount
= 2, dependsOnMethods ="testRunWindowsTestsInSequence" )
public void testRunWindowsTestsInParallel()
{
}
@DataProvider(name = "windows")
public Iterator getWindowsIterator() {
return new DataIterator("WINDOWS");
}
}
//Sample testng configuration file
<suite name="OSTest" junit="false" annotations="JDK">
<parameter name="a" value="127.0.0.1"/>
<parameter name="b" value="administrator"/>
<parameter name="c" value="password"/>
<test verbose="2" name="Windows Tests" annotations="JDK5">
<groups>
<run>
<include name="windowsTests"/>
</run>
</groups>
<classes>
<class name="Test"/>
<methods>
<include name="testRunWindowsTestsInSequence"/>
<include name="testRunWindowsTestsInParallel"/>
</methods>
</classes>
</test>
</suite>
The BeforeSuite and BeforeClass annotated methods are not called and
the methods in the group require session details to run the tests.
Am I missing something here?
Thanks.
Your configuration methods (@BeforeSuite & @BeforeClass) must also be
in the desired group. When running in a group context, only those
methods in the specified groups will be executed. That includes
configuration methods. It is best to look at the running of a
configuration method as if were a test. This behavior initially
confused us as well.
If you always want the configuration methods to run regardless of
group, then set alwaysRun=true.
Cheers,
-John
Many thanks for your reply.
I have few more questions regarding the grouping concepts.
1. Are the configuration methods inherited?
Eg.
@Test(groups = {"All"})
class SuperTests
{
@BeforeSuite(groups = {"All"},alwaysRun=true)
public void setUp()
{
//Set values from testng configuration xml file
}
}
Class SubClass extends SuperClass
{
@Test(groups = {"windowsTests"})
{
}
@Test(groups = {"linuxTests"})
{
}
@Test(groups = {"macTests"})
{
}
}
After running the tests when I look at the index.html file in the test
output directory, I see tests (windows, linux and mac group methods
included under All groups.
Pls. confirm.
Thanks
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.