- Click on Project
- CNTL+ENTER
- Go to general file
- Create a file in your project with name testng.xml
- click on finish
- Open that file and write the given below code
Change the names according to your program and run that testng.xml Run as Testng
it will run your program with Testng
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite Name" >
<!-- suite name="Suite Name" -->
<test name="TestA" allow-return-values="true">
<classes>
<!-- packagename.Testcase class name -->
<class name ="listnerDemo.Testcases" />
</classes>
</test>
<listeners>
<!-- packagename.customerlistner_classname -->
<listener class-name="listnerDemo.CustomerListner"/>
</listeners>
</suite>
*********************************if you have to run using multiple suite********
let me give you an example
if you have three suites that have multiple cases then create the tree .xml file and write the code as above for all the three suite
then create a testng.xml file that will include the code as below
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<Suite name="Data driver testng project">
<Suite-files>
<Suite-files path="C:\Arpan\Study Documents\Selenium\Selenium Framework\Core_Framework_TestNG\suiteA.xml" />
<Suite-files path="C:\Arpan\Study Documents\Selenium\Selenium Framework\Core_Framework_TestNG\suiteB.xml" />
<Suite-files path="C:\Arpan\Study Documents\Selenium\Selenium Framework\Core_Framework_TestNG\suiteC.xml" />
</Suite-files>
</Suite>
Then run the testng.xml Run as Testng then it will run all the program of those are part of these three suites