What is the purpose of the testng.xml file?

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




   
   
      
         
            
         
      
   

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.

Updated on: 2020-06-11T12:25:18+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements