2

As stated in Gradle compiles but does not run TestNG tests I am having some trouble getting gradle to play nicely with TestNG. It just seems like no tests are being executed no matter what I try. So I went and tried to force gradle into executing specific tests using the --tests command line parameter.

However, when I run this the build fails with this message: Test filtering is not supported for given version of JUnit. Please upgrade JUnit version to at least 4.6.

Now I know TestNG is based on JUnit, so it might be unrelated to my earlier issue, but is there a chance that this indicated TestNG is actually never really used? Is it trying to run the tests as JUnit tests instead? How would I know?

As a bonus: how can I upgrade the used JUnit version? I am only including testng:

    dependencies {
        compile 'javax.inject:javax.inject:1'
        compile 'org.springframework:spring-context:4.1.4.RELEASE'
        compile 'org.springframework:spring-core:4.1.4.RELEASE'
        compile 'org.springframework:spring-beans:4.1.4.RELEASE'
        compile 'org.springframework.data:spring-data-mongodb:1.6.1.RELEASE'
        compile 'org.springframework.data:spring-data-jpa:1.7.1.RELEASE'
        compile 'org.hibernate:hibernate-entitymanager:4.3.8.Final'
        compile 'mysql:mysql-connector-java:5.1.34'
        compile 'commons-logging:commons-logging:1.2'
        testCompile 'org.springframework:spring-test:4.1.4.RELEASE'
        testCompile 'org.testng:testng:6.1.1'
    }
}
Community
  • 1
  • 1
titusn
  • 1,201
  • 1
  • 12
  • 43

1 Answers1

0

It turns out that indeed TestNG was never used. We have a multi-project build and the subprojects were accidentally still configured to use JUnit. See https://stackoverflow.com/a/28171157/1788160

Community
  • 1
  • 1
titusn
  • 1,201
  • 1
  • 12
  • 43
  • I don't see what TestNG has to do with this problem. I haven't declared TestNG anywhere, and am still facing the aforementioned error. – IgorGanapolsky Apr 06 '15 at 20:07
  • You are getting the error, because you are using JUnit. If you read my answer you will see that I wanted to turn on TestNG, but it did not work, so Gradle switched to the default JUnit. The error actually had nothing to do with TestNG. – titusn Apr 08 '15 at 09:18