Earlier we have seen ways to rerun the TestNG tests when there are failures due to many exceptions such as 'NoSuchElementException', 'NoSuchWindowException' 'TimeOutException', 'StaleElementReferenceException' or any other failures.
Gradle is an open-source build automation tool that is designed to be flexible enough to build almost any type of software. Gradle runs on the JVM and you must have a Java Development Kit (JDK) installed to use it. You can find more information on Gradle
You can install the Gradle build tool on Linux, macOS, or Windows.
Allure is an open-source framework designed to create interactive and comprehensive test report by Yandex QA Team
Each time when we run automation tests, we will have test results to view details about no. of tests passed, failed and failure details etc. And few reports also include test failure screenshots. We have discussed selenium examples on Extent report and testng custom report with screenshots.
SoftAssert in TestNG helps to collect all the assertions throughout the
@Test method. And to see assertions result at the end of the test, we have to invoke
SoftAssert don't throw an exception when an assert fails, but it records the failure. The test execution will continue with the next step after the assert statement. Calling
assertAll() will cause an exception to be thrown if at least one assertion failed.
As we know, TestNG provides default html reports with basic information like No. of tests passed, failed, skipped and time taken to execute these tests in milliseconds. But you may not find it very helpful as the reports generated by TestNG has very little information.
IMethodInterceptor is used to alter/modify the list of test methods to be executed by TestNG.
When we implement
IMethodInterceptor interface which has just one method to implement
'intercept(java.util.List, using this method we can reorder the list of test methods and return List of IMethodInstance which TestNG runs. TestNG will now run these test methods in the same order which is found in the returned list.
In previous tutorial we have seen executing testng.xml tests from command line. Now here we will look into executing testng.xml using batch file (.bat) file. A batch file (.bat) is used in DOS and Windows, which is an unformatted text file that consists of a series of commands to be executed by the command line interpreter.
Let us jump into simple example by taking two classes each has three or more @Test methods.
We can execute testng.xml file in different ways.
3. Ant / Maven
4. Command Line
5. Batch File.
Please visit for the updated article customized emailable report along with screenshots which works perfect for newer versions of testNG and tested with testng latest version 6.14.3
This example was using older testng version.
When ever we execute tests with TestNG, it will generate a default html report with basic information.
As we know, we can pass parameter values to the test methods during run time from testng xml file by specifying Parameters annotation to test method.
To do this, we need to declare parameters tag in xml file using 'name' and 'value' attribute.Where the name attribute of the tag defines name of the parameter and the value attribute defines the value of the parameter.