TestNG - Add Multi Test Cases in One Class & Test Suite - Test Automation - Selenium - Mr Beat Coder
Вставка
- Опубліковано 13 тра 2024
- Created with Wondershare Filmora
Mr Beat Coder
Test Automation - TestNG - Add Multi Test Cases in One Class & Importance of testing.xml file and Test Suite in TestNG Configuration
Steps:
1. Add additional test cases in the Single Class, by adding @Test, followed by the method and the code
Each @Test is an individual test case within the Single Class
package TestNGFramework;
import org.testng.annotations.Test;
public class TestNGDay1 {
@Test
public void Demo() {
// TODO Auto-generated method stub
System.out.println("Hello World");
}
@Test
public void SecondTest() {
// TODO Auto-generated method stub
System.out.println("Bye World");
}
}
2. Add more new Java Classes and name them for Example as Day1, Day2
Add Test Case(s) in these new Java Classes
Right-click on the Project folder and select “TestNG”, then select “Convert to TestNG”. This creates a new “Testing.xml” file, which is our Testing Suite
The hierarchy in the Testing Suite:
Test Suite (e.g. Insurance) - Test Class (folder/ modules e.g. Personal Insurance/ Commercial Insurance/ Rural Insurance) - Test Cases
3. Now, we can run all the test cases in the Test Suite, by right-clicking in the “Testing.xml” file and running the code with TestNG