'Gradle Issue with TestNG : No tests found for given includes

I am having difficulties with testNG + Gradle. My tests have worked fine, but I made some changes to the file where I have tests, and now this issue pops up.

"Execution failed for task ':....'.

No tests found for given includes : [.....]

I have this in place, but it doesn't help.

test {
    useTestNG()
}

What does error mean exactly, and how do I resolve it?



Solution 1:[1]

I had this same problem when running TestNG tests from within IntelliJ. I've found that many posts recommend changing the "Run test using" setting from "Gradle" to "IntelliJ IDEA" (Settings/Build,Execution, Deployment/Build Tools/Gradle), but this didn't work for me.

I discovered that on the same settings screen my "Gradle JVM" was set to using a newer JVM: "JVM 11" when our code is only compatible with "JVM 1.8". Changing this setting fixed the above error.

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 Jason White