Introduction
Before we dive into the concepts of Automation Testing, let us first understand what testing is and the significant reasons to perform Software Testing.
In the modern world, there is a thriving need for new software. With the release of new software, the developers need to ensure that the software acts according to its functionality. To achieve this, each software goes through a series of tests. The testing engineers strive to catch the errors and bugs before releasing the software into the market. Even with the presence of the best manual testing processes, the software is sometimes left with undetected bugs or is unable to meet the user requirements. This is where Automation Testing comes into action. It is one of the most precise and effective ways to perform Software Testing. We can use the TestNG framework present in Selenium to achieve Automation Testing.
Multiple Test Cases
We can implement multiple test cases using the TestNG test suite in Selenium. We further have to implement parallel execution of the test cases to run them simultaneously. All the configurations for the parallel execution are made in the XML file.
Let us look at an example to understand it better,
import org.testng.annotations.Test;
public class multipleTest {
@Test
public void FirstTestCase() {
driver.close();
System.out.println("This is the first test case");
}
@Test
public void SecondTestCase() {
System.out.println("This is the second test case");
}
@Test
public void ThirdTestCase(){
System.out.println("This is the third test case");
}
@Test
public void FourthTestCase(){
System.out.println("This is the fourth test case");
}
}
In the above file, we create four test cases that will be called inside the XML file.
TestNG XML File
<suite name="Test-Suite" parallel="methods" thread-count="4">
<test name="Multiple Test" >
<classes>
<class name="multipleTest" />
</classes>
</test>
</suite>
In the above XML file, we create the parallel method and assign the number of threads as four.