java Gradle 没有运行测试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29868724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gradle not running tests
提问by jvermeulen
For some reason gradle is not running my tests. When i execute gradle cleanTest test -i
i get:
由于某种原因,gradle 没有运行我的测试。当我执行gradle cleanTest test -i
我得到:
Skipping task ':compileJava' as it is up-to-date (took 0.262 secs).
:compileJava UP-TO-DATE
:compileJava (Thread[main,5,main]) completed. Took 0.266 secs.
:processResources (Thread[main,5,main]) started.
:processResources
Skipping task ':processResources' as it has no source files.
:processResources UP-TO-DATE
:processResources (Thread[main,5,main]) completed. Took 0.001 secs.
:classes (Thread[main,5,main]) started.
:classes
Skipping task ':classes' as it has no actions.
:classes UP-TO-DATE
:classes (Thread[main,5,main]) completed. Took 0.0 secs.
:compileTestJava (Thread[main,5,main]) started.
:compileTestJava
Skipping task ':compileTestJava' as it has no source files.
:compileTestJava UP-TO-DATE
:compileTestJava (Thread[main,5,main]) completed. Took 0.001 secs.
:processTestResources (Thread[main,5,main]) started.
:processTestResources
Skipping task ':processTestResources' as it is up-to-date (took 0.004 secs).
:processTestResources UP-TO-DATE
:processTestResources (Thread[main,5,main]) completed. Took 0.007 secs.
:testClasses (Thread[main,5,main]) started.
:testClasses
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
file or directory '/Users/jan/2014-2015-groep-05/VoPro/build/classes/test', not found
Skipping task ':test' as it has no source files.
My test are in the folder ./test/
. And this is my gradle config:
我的测试在文件夹中./test/
。这是我的 gradle 配置:
apply plugin: 'java'
apply plugin: 'eclipse'
test {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
dependsOn 'cleanTest'
}
repositories {
mavenCentral()
}
dependencies {
testCompile("junit:junit")
}
sourceSets {
main {
java {
srcDir 'src'
srcDir 'test'
}
}
}
I can't seem to find what the problem is. Gradle does not recognize any tests, since both test and cleanTest are always up to date, however i did add test/ to my sourceSets.
我似乎无法找到问题所在。Gradle 无法识别任何测试,因为 test 和 cleanTest 始终是最新的,但是我确实将 test/ 添加到我的 sourceSets 中。
采纳答案by JB Nizet
You're saying that the mainSourceSet should contain the test directory. This directory should be set in the testSourceSet.
您是说主SourceSet 应该包含测试目录。这个目录应该在测试SourceSet中设置。
回答by timekeeper
Replace sourceSets with below simple snippet:
用下面的简单片段替换 sourceSets:
sourceSets.main.java.srcDirs = ['src']
sourceSets.test.java.srcDirs = ['tst']