Creating And Running WebDriver Test Suit Using testng.xml File
Last updated
Was this helpful?
Last updated
Was this helpful?
Creating testng.xml File
To create testng.xml file, Right click on project folder and Go to New -> File ->testng.xml
: suite tag defines the TestNG suite. You can give any name to your suite using 'name' attribute. In above given example, We have given "Suite One" to our test suite.
: test tag defines the TestNG test. You can give any name to your test using 'name' attribute. In above given example, We have given "Test One" to our test
. : classes tag defines multiple class. We can multiple test class under classes tag. In our example we have only one class.
: class tag defines the class name which you wants to consider in test execution. In above given example, we have defined name="TestNGOne.ClassOne" where ' TestNGOne ' describes package name and 'ClassOne' describes class name.
To Run Right click on testng.xml file -> Run As -> Select TestNG Suite
First of all, Create 3 classes under project = TestNGOne and package = TestNGTest as bellow.
"BaseClass" will be used for initializing and closing webdriver instance,
"ClassOne" and "ClassTwo" will be used as test classes.
We are defining two attributes 'parallel' and 'thread-count' at suite level. As we want test methods to be executed in parallel, we have provided 'methods'. And 'thread-count' attribute is to use to pass the number of maximum threads to be created.
Dependency means if one @Test method fails or skipped from execution then its dependent @Test method must not be executed.