【发布时间】:2017-02-06 03:44:43
【问题描述】:
我正在尝试创建一个新的 gradle 项目来测试一些代码,但我无法运行测试用例。
我的文件夹结构如下:
- src
- main
- groovy
- java
- resources
- test
- groovy
- java
- resources
我的 build.gradle:
group 'test'
version '1.0-SNAPSHOT'
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
还有一个测试,在 src/test/groovy:
import groovy.util.logging.Log
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@Log
@RunWith(JUnit4.class)
class TestA {
TestA() {
println "hello"
}
@Test
void "test"() {
println "a"
log.info("b")
}
}
当我通过命令行运行 ./gradlew.bat test 时,我得到了这个:
{ test } » ./gradlew.bat test
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:compileTestGroovy
:processTestResources UP-TO-DATE
:testClasses
:test
BUILD SUCCESSFUL
Total time: 5.333 secs
一切都应该是正确的,但没有打印出来,我不知道为什么。
【问题讨论】:
标签: testing gradle groovy junit