Selenium - Run test cases in batch
There is a provision to run tests in batch with the following technique in TestNG. This is a TestNG feature.
a) So far we have seen executing only one Testclass file and all the tests in that particular test class file running with TestNG class
b) Now we will see how to run or execute multiple class files with the help of xml file. This file is generally named as testng.xml but you can name it as whatever you want but the file type should be xml.
Even if you don't create a TestNG suite for one class, TestNG automatically create a default suite for each execution.
c) If you don't know how to create testng.xml file then do the following:
d) Right click on Project and you can see TestNg-> Convert to TestNG.
e) Then click on Next and then Finish
Once finished, the following file will be generated under the project folder.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<test thread-count="5" name="LoginTest">
Explanation of testng.xml:
a) You can choose any name for test and suite tags. Here I have given LoginSuite and LoginTest.
b) But for classes you have to provide exact class path of the Test Classes.
c) Now if you want to run all the test classes (Multiple Test classes) , right click on testng.xml file and select Run as-> Test Suite and all the tests in both classes Login Functionality and Demo files are executed.
Now verify the console below:
[RemoteTestNG] detected TestNG version 6.14.3
Inside test case 1
User enters the login data
User Successfully logged in
Logged out to User account
Total tests run: 2, Failures: 0, Skips: 0
You can verify both tests in both class files are executed and passed. This is called running TestNG files in batch.