为什么gradle命令行不显示specs2结果?

时间:2015-11-03 15:48:39

标签: java scala gradle specs2 scalacheck

我有一个scala项目,其中包含java项目的specs2 scalacheck规范。

我可以在eclipse和所有测试通过中使用JUnitRunner运行规范。

我也可以执行gradle测试任务,但是我没有看到任何关于测试的控制台输出。

这是我的build.gradle文件:

apply plugin: 'scala'
apply plugin: 'eclipse'

ext {
    scalaVersion                  = "2.11.+"
    specs2ScalaVersion            = "2.11"
    specs2ScalacheckVersion       = "3.1.1"
    dependencyJunit               = "junit:junit:4.+"
}

sourceCompatibility = 1.8
version = '1.0'
jar {
    manifest {
        attributes 'Implementation-Title': 'camm-shared specs',
                   'Implementation-Version': version
    }
}

repositories {
    maven { url "http://dl.bintray.com/scalaz/releases" }
    mavenCentral()
}


dependencies {
    compile "org.scala-lang:scala-library:$scalaVersion"
    compile files('../lib/MarketInterface.jar')
    compile project(':camm-shared')

    testCompile "org.specs2:specs2-core_$specs2ScalaVersion:$specs2ScalacheckVersion"
    testCompile "org.specs2:specs2-scalacheck_$specs2ScalaVersion:$specs2ScalacheckVersion"
    testCompile "org.specs2:specs2-junit_$specs2ScalaVersion:$specs2ScalacheckVersion"
    testCompile dependencyJunit
}

test {
  //makes the standard streams (err and out) visible at console when running tests
  testLogging.showStandardStreams = true
}

test {
  onOutput { descriptor, event ->
    logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
  }
}

我已经尝试过通过配置测试任务获得控制台输出的建议,但这并没有解决问题。

当我清理项目并运行测试任务时,它需要应用程序。 20秒,所以它可能会运行所有测试,但不会失败。他们在日食中的JUnitRunner也需要大约20秒 - 我有minTestOk = 100000

1 个答案:

答案 0 :(得分:3)

Gradle(当前)无法自动识别Specs2测试,因此不会立即运行它们。如果希望Gradle运行Specs2测试,则必须使用JUnit的@RunWith注释装饰测试类,或者为其编写指定的任务。两个选项are explained in the official Specs2 documentation