How to create "testng.xml" using Eclipse

I am new to TestNG and Selenium Webdriver and am trying to create testng.xml using eclipse.

We did some research on the WWW and realized that this file can be created by right-clicking on the Java class β†’ TestNG β†’ Convert to TestNG

However, this Convert Refactoring editor does not open.

Would this wizard open if the Java class already contains @Test annotations (!?)

Help me create testng.xml using eclipse.

(I use Eclipse Luna)

+4
source share
4 answers

The testng package file was created manually, as shown below:

  • Run after your project
  • Refresh Project
  • Now the folder "test-output" will be created in your project - expand the folder
  • index.html; Eclipse
  • ".xml", .
  • XML
  • XML
  • β†’ β†’
  • ( .xml, , testng.xml) "".
  • , "index.html", .
+10
  • 1: , .
  • 2:
  • 3: TestNG , .
  • 4: " TestNG"
  • 5: "Generate testng.xml"
  • 6: "", .
+1

, , testNG,

testng.xml, , , , testng.xml testng.

0
  • ""
  • CNTL + ENTER
  • testng.xml

testng.xml Testng 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 need to run multiple packages ****** **

let me give an example if you have three sets that have several cases, then create an XML tree file and write the code, as described above, for all three packages

then create a testng.xml file that will contain the code 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 testng.xml Run as Testng, then it will run the entire program from these three packages

0
source

Source: https://habr.com/ru/post/1589235/


All Articles