TestNG integration with Gradle

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" >

            <package name="groupstests"/>


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.

test {
    useTestNG {
        suites 'src/test/resources/testng.xml'

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 http://www.softpost.org/gradle/executing-testng-tests-in-gradle-project

You may also like...