2015-11-03 81 views
2

我有一個scala項目,其中包含一個java項目的specs2 scalacheck規範。爲什麼gradle命令行不顯示specs2結果?

我能夠與運行在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秒,所以它可能運行所有的測試,這不會失敗。他們在Eclipse中的JUnitRunner也需要大約20秒 - 我有minTestOk = 100000

+0

你弄清楚如何讓這個工作?我用@RuNWith等裝飾了我的測試類,但仍然沒有看到任何輸出。此答案中的鏈接爲 –

回答

1

搖籃(目前)不能自動識別Specs2測試,因此並不運行它們外的開箱。如果您希望Gradle運行Specs2測試,則必須使用JUnit的@RunWith批註修飾您的測試類,或者爲其編寫指定的任務。兩個選項are explained in the official Specs2 documentation

+0

404。 –

相關問題