Was it helpful?

Question

What is the purpose of the testng.xml file?

TestNGJava Programming Framework

The testng.xml file has the numerous uses as listed below −

  • Test cases are executed in groups.

  • Test methods can be included or excluded in the execution.

  • The execution of multiple test cases from multiple java class files can be triggered.

  • Comprises names of the folder, class, method.

  • Capable of triggering parallel execution.

  • Test methods belonging to groups can be included or excluded in the execution.

Example

TestNG.xml file

<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name = "Cycle1">
   <test name = "Tutorialspoint">
   <classes>
      <class name = "Test1" />
         <methods>
            <exclude name= “Login.*”/>
         </methods>
      </classes>
   </test>
</suite>

Here as per the xml file, all the test methods with starting name Login will be excluded from test execution.

Example

@Test
public void VerifyPay(){
   System.out.println("Verify payment is successful”);
}
@Test
public void LoginAdmin(){
   System.out.println("Login is successful in admin”);
}
@Test
public void LoginSystem(){
   System.out.println("Login is successful”);
}

Here as per the java class file, only VerifyPay() will be executed since all methods starting with name Login will be excluded from test execution.

raja
Published on 11-Jun-2020 15:55:18
Advertisements
Was it helpful?
Not affiliated with Tutorialspoint
scroll top