TestNG Tutorial
Introduction to TestNG Configuration and set up of TestNG project Simple TestNG project in IntelliJ IDEA TestNG annotations Assertions in TestNG Difference between assertEquals and assertSame Ignoring the tests in TestNG Grouping the tests timeOut tests in TestNG Exception tests in TestNG dependsOnMethods dependsOnGroups Hard and Soft dependencies Passing parameters using XML file Passing parameters using Data providers Dynamic Data Providers group-by-instances attribute in TestNG XML suite file Test priorities in TestNG invocationCount in TestNG Executing Selenium tests using TestNG Executing TestNG tests using main method Executing JUnit tests from within TestNG Running tests in Parallel in TestNG Executing only failed tests in TestNG TestNG integration with Maven TestNG integration with Gradle Reporter class in TestNG TestNG Reports Execution Listener Test Listener Comparison between JUnit and TestNGgradle integration in testng
In this topic, let us see how to run the TestNG XML suite file in Gradle project. You will have to create below XML test suite file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Softpost Suite">
<test name="softpostTests" preserve-order="true" >
<packages>
<package name="groupstests"/>
</packages>
</test>
</suite>
You will have to use below lines in build.gradle to use TestNG XML suite file. Notice that you will have to provide entire path starting from src directory. After this, you can run test task from Gradle. It will execute the tests as specified in XML file. You can find more information on TestNG and Gradle at https://www.softpost.org/gradle/executing-testng-tests-in-gradle-project
test {
useTestNG {
suites 'src/test/resources/testng.xml'
}
}
Web development and Automation testing
solutions delivered!!