跑步时没有试运行"玩jacoco:test"而#34;玩测试"工作良好

时间:2014-06-24 15:47:00

标签: java junit playframework playframework-2.2 jacoco

我正在尝试在play框架环境中对我的junit测试运行jacoco。 我可以使用以下方式运行它们:

玩jacoco:test

但结果是:

[info] Loading project definition from /home/git/release-internal/project
[info] Set current project to delivery (in build file:/home/git/release-internal/)
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] No tests to run for jacoco:test
[success] Total time: 1 s, completed Jun 24, 2014 5:37:20 PM

如果我进行“游戏测试”,那么我的所有junit测试运行正常,那么缺少什么?

这是我的Build.scala文件:

import sbt._
import Keys._
import play.Project._
import de.johoop.jacoco4sbt._
import JacocoPlugin._

object ApplicationBuild extends Build {

  val appName         = "delivery"
  val appVersion      = "0.5"

  val appDependencies = Seq(
    // Add your project dependencies here,
    cache,
    javaCore,
    javaJdbc,
    javaEbean,
    "mysql" % "mysql-connector-java" % "5.1.18",
    "com.typesafe" %% "play-plugins-mailer" % "2.1-RC2",
    "com.novocode" % "junit-interface" % "0.9" % "test"
  )

  lazy val s = Defaults.defaultSettings ++ Seq(jacoco.settings:_*)

  val main = play.Project(appName, appVersion, appDependencies, settings = s).settings(
    // Add your own project settings here
    javaOptions in Test += "-Dconfig.file=conf/test.conf",
    testOptions in jacoco.Config ++= Seq(
        Tests.Setup { () => System.setProperty("play.base.dir", baseDirectory.value.toString) },
        Tests.Cleanup { () => System.clearProperty("plase.base.dir") }
    ),
    // Workaround for defect
    // https://github.com/playframework/playframework/issues/1437
    testOptions in Test ~= { args =>
        for {
          arg <- args
          val ta: Tests.Argument = arg.asInstanceOf[Tests.Argument]
          val newArg = if(ta.framework == Some(TestFrameworks.JUnit)) ta.copy(args = List.empty[String]) else ta
        } yield newArg
      },
    parallelExecution     in jacoco.Config := false,
    jacoco.reportFormats  in jacoco.Config := Seq(XMLReport("utf-8"), HTMLReport("utf-8")),
    jacoco.excludes       in jacoco.Config := Seq("views.*", "controllers.Reverse*", "controllers.javascript.*", "controllers.ref.*", "Routes*")
  )

}

和我的plugins.sbt

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.2")

libraryDependencies ++= Seq(
  "org.jacoco" % "org.jacoco.core" % "0.5.9.201207300726" artifacts(Artifact("org.jacoco.core", "jar", "jar")),
  "org.jacoco" % "org.jacoco.report" % "0.5.9.201207300726" artifacts(Artifact("org.jacoco.report", "jar", "jar")))

addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.5")

很多

0 个答案:

没有答案