2015-04-18 86 views
1

我試圖用jacoco將測試報告集成到我的sbt項目中。 https://github.com/sbt/jacoco4sbt執行sbt任務命令時看不到jacoco任務(-v也試過)

我加jacoco.settingsbuild.sbt

我還添加了addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6")plugins.sbt

當我運行sbt jacoco:check,它工作正常。但是,當我試圖查看jacoco有多少任務時,sbt tasks未顯示與jacoco相關的任何內容。

我必須去源代碼來看看它。

https://github.com/sbt/jacoco4sbt/blob/master/src/main/scala/de/johoop/jacoco4sbt/Keys.scala

我可以知道爲什麼沒有顯示爲sbt tasks命令jacoco,什麼是看的插件

編輯所有可用的任務最好的方法:

我懷疑聲明lazy val Config = config("jacoco") extend(Test) hide意味着jacoco擴展了Test任務,所以它不會在sbt任務中顯示它,但我不確定。

回答

1

通過運行

> tasks -v 

編輯:如果不工作考慮增加更多的「v」可以,如tasks -vvv,甚至tasks -V看到所有的任務。

我明白了,例如,cover

This is a list of tasks defined for the current project. 
It does not list the scopes the tasks are defined in; use the 'inspect' command for that. 
Tasks produce values. Use the 'show' command to run the task and print the resulting value. 

    check     Executes the tests and saves the execution data in 'jacoco.exec'. 
    classesToCover   compiled classes (filtered by includes and excludes) that will be covered 
    clean     Cleaning JaCoCo's output-directory. 
    compile    Compiles sources. 
    console    Starts the Scala interpreter with the project classes on the classpath. 
    consoleProject   Starts the Scala interpreter with the sbt and the build definition on the classpath and useful imports. 
    consoleQuick   Starts the Scala interpreter with the project dependencies on the classpath. 
    copyResources   Copies resources to the output directory. 
    cover     Executes the tests and creates a JaCoCo coverage report. 
    coveredSources   Covered Sources. 

還要注意說話是算數的開頭(包裝爲清楚起見):

It does not list the scopes the tasks are defined in; 
    use the 'inspect' command for that. 

導致

> inspect cover 
[info] No entry for key. 
[info] Description: 
[info] Executes the tests and creates a JaCoCo coverage report. 
[info] Delegates: 
[info] *:cover 
[info] {.}/*:cover 
[info] */*:cover 
[info] Related: 
[info] jacoco:cover 

所以你知道運行jacoco:cover

+0

任務-v在pure sbt項目中顯示jacoco任務,但它並不顯示任何在框架項目中的作用。但謝謝你的回答 –

+0

@Cloudtech我明白你的意思。我已經添加了有關如何在簡單的遊戲應用中查看的詳細信息。 –