Gradle不运行TestNG测试,即使使用test.useTestNG() [英] Gradle not running TestNG tests, even with test.useTestNG()

查看:955
本文介绍了Gradle不运行TestNG测试,即使使用test.useTestNG()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 build.gradle 看起来像这样:

  apply plugin :'scala'
apply plugin:'java'

sourceCompatibility = 1.8
version ='1.0'

存储库{
mavenCentral )
}

依赖项{
compile'org.scala-lang:scala-library:2.11.4

compile'org.reactivestreams: reactive-streams:1.0.0.RC1'
compile'org.reactivestreams:reactive-streams-tck:1.0.0.RC1'

testCompile group:'junit',name:' junit',版本:'4.11'
testCompile组:'org.testng',名称:'testng',版本:'5.14.10'
}

test {
useTestNG()
}

我在Scala和TestNG测试中有一些实现在Java中。测试类实际上不包含任何测试,但它是父类。 Gradle似乎认为课堂上没有任何测试。

 跳过任务':testClasses',因为它没有动作。 
:testClasses UP-TO-DATE
:testClasses(Thread [main,5,main])已完成。花了0.001秒。
:test(线程[main,5,main])开始。
:测试
跳过任务':测试',因为它是最新的(花费0.048秒)。
:test最新日期

测试类被编译为 build / classes / test

解决方案

tl; dr



将以下代码添加到 build.gradle

  tasks.withType(Test){
scanForTestClasses = false
include** / * Test.class//任何Ant模式都与您的测试类文件匹配
}

说明: p> 这里是导致遇到问题的错误。并且可以找到此处的解决方案。不要忘记加注所有答案(我的意思是彼得的);)

My build.gradle looks like this:

apply plugin: 'scala'
apply plugin: 'java'

sourceCompatibility = 1.8
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    compile "org.scala-lang:scala-library:2.11.4"

    compile 'org.reactivestreams:reactive-streams:1.0.0.RC1'
    compile 'org.reactivestreams:reactive-streams-tck:1.0.0.RC1'

    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile group: 'org.testng', name: 'testng', version: '5.14.10'
}

test {
    useTestNG()
}

I have some implementation in Scala, and TestNG test in java. The test class actually does not contain any tests, but it's parent class does. Gradle seems to think there are no tests in the class.

Skipping task ':testClasses' as it has no actions.
:testClasses UP-TO-DATE
:testClasses (Thread[main,5,main]) completed. Took 0.001 secs.
:test (Thread[main,5,main]) started.
:test
Skipping task ':test' as it is up-to-date (took 0.048 secs).
:test UP-TO-DATE

The test class is compiled in build/classes/test

解决方案

tl;dr

Add the following piece of code to build.gradle:

tasks.withType(Test) {
    scanForTestClasses = false
    include "**/*Test.class" // whatever Ant pattern matches your test class files
}

explanation:

Here's the bug that causes problem you met. And here the solution can be found. Don't forget to upvote all answers (I mean Peter's) ;)

这篇关于Gradle不运行TestNG测试,即使使用test.useTestNG()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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