2015-04-18 63 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我明白你的意思。我已经添加了有关如何在简单的游戏应用中查看的详细信息。 –