'How to run testng xml using gradle?

I am trying to run testng.xml using gradle task but looks like its not picking it. Can someone please help me in identifying what I am missing here? Do I need to pass the path of testng.xml somewhere?

build.gradle 

    test {
        useTestNG {
            useDefaultListeners = true   
    }


Solution 1:[1]

Yes, you need to tell gradle where your TestNG suite xml is located if you want it to use one. Assuming that your test.xml file is located inside of src/test directory of your project it would look like this:

test {
    useTestNG {
        suites "src/test/testng.xml"
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 erdi