Gradle在TestNG任务上抱怨JUnit版本 [英] Gradle complains about JUnit version on TestNG task

查看:143
本文介绍了Gradle在TestNG任务上抱怨JUnit版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

a>我在使用TestNG与Gradle很好地玩时遇到了一些麻烦。这似乎没有任何测试正在执行,不管我尝试什么。所以我去试着强制gradle使用 - tests 命令行参数执行特定的测试。

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.

然而, ,当我运行它时,构建失败并显示以下消息:
给定版本的JUnit不支持测试过滤。请将JUnit版本升级至4.6以上。

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.

现在我知道TestNG基于JUnit,所以它可能与我之前的问题无关,但是有没有机会说明TestNG实际上从未真正使用过?它试图以JUnit测试的方式运行测试吗?我如何知道?

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?

作为奖励:我如何升级使用的JUnit版本?我只包括testng:

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'
    }
}


推荐答案

TestNG从未使用过。我们有一个多项目构建,并且子项目被意外地配置为使用JUnit。请参阅 https://stackoverflow.com/a/28171157/1788160

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

这篇关于Gradle在TestNG任务上抱怨JUnit版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆