Gradle 不是 运行 TestNG 测试,即使使用 test.useTestNG()
Gradle not running TestNG tests, even with test.useTestNG()
我的 build.gradle
看起来像这样:
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()
}
我在 Scala 中有一些实现,在 java 中进行了 TestNG 测试。测试 class 实际上不包含任何测试,但它的父级 class 包含任何测试。 Gradle 似乎认为 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
测试class编译在build/classes/test
tl;dr
将以下代码添加到build.gradle:
tasks.withType(Test) {
scanForTestClasses = false
include "**/*Test.class" // whatever Ant pattern matches your test class files
}
解释:
Here's the bug that causes problem you met. And here可以找到解决办法。不要忘记为所有答案投票(我的意思是彼得的);)
我的 build.gradle
看起来像这样:
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()
}
我在 Scala 中有一些实现,在 java 中进行了 TestNG 测试。测试 class 实际上不包含任何测试,但它的父级 class 包含任何测试。 Gradle 似乎认为 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
测试class编译在build/classes/test
tl;dr
将以下代码添加到build.gradle:
tasks.withType(Test) {
scanForTestClasses = false
include "**/*Test.class" // whatever Ant pattern matches your test class files
}
解释:
Here's the bug that causes problem you met. And here可以找到解决办法。不要忘记为所有答案投票(我的意思是彼得的);)