sbt sub project testOnly(scalatest)不工作

时间:2018-04-09 07:30:57

标签: sbt scalatest

我遇到问题,我无法使用testOnly为特定模块运行一个测试..

lazy val root = (project in file("."))
  .settings(Commons.settings: _*)
  .aggregate(utils, `some-service`, otherService)

如果我在某人:project some-service然后testOnly *MyTest 我收到了一个错误:

[error] Expected ID character
[error] Not a valid command: testOnly
[error] Expected project ID
[error] Expected configuration
[error] Expected ':' (if selecting a configuration)
[error] Expected key
[error] Expected '::'
[error] Expected end of input.

运行所有测试工作正常,但不仅仅是特定的测试。 谁知道怎么做? 谢谢!

编辑:

val settings: Seq[Def.Setting[_]] = Seq(
    version := appVersion,
    scalaVersion := "2.11.11",
    resolvers += Opts.resolver.mavenLocalFile,
    resolvers += "conjars" at "http://conjars.org/repo",
    resolvers += "clojars" at "https://clojars.org/repo",
    resolvers += "RedisLabs" at "https://dl.bintray.com/spark-packages/maven/",
    scalacOptions ++= Seq(
      "-unchecked",
      "-deprecation",
      "-feature",
      "-language:existentials",
      "-language:higherKinds",
      "-language:implicitConversions",
      "-language:postfixOps",
      "-Ywarn-dead-code",
      "-Ywarn-infer-any",
      "-Ywarn-unused-import",
      "-Xfatal-warnings",
      "-Xlint"
    )
  )

lazy val `some-service` = (project in file(s"$servicePrefix-service"))
  .settings(Commons.settings: _*)
  .settings(
    libraryDependencies ++= someService
  )
  .settings(
    Seq(
      daemonUser.in(Docker) := "root",
      version.in(Docker) := "latest",
      dockerBaseImage := "openjdk:8",
      dockerExposedPorts := Vector(8080),
      javaOptions in Test += "-Dconfig.resource=application.test.conf",
      fork in Test := true,
      startDynamoDBLocal := startDynamoDBLocal.dependsOn(compile in Test).value,
      test in Test := (test in Test).dependsOn(startDynamoDBLocal).value,
      testOnly in Test := (testOnly in Test).dependsOn(startDynamoDBLocal).value,
      testOptions in Test += dynamoDBLocalTestCleanup.value
      //dynamoDBLocalInMemory := false ,
      //dynamoDBLocalDBPath := Some("local-db/"),
      //dynamoDBLocalCleanAfterStop := true
    )
  )
  .dependsOn(utils, otherService)
  .enablePlugins(JavaAppPackaging, DockerPlugin)

1 个答案:

答案 0 :(得分:1)

好的,我找到了一个理由。

testOnly in Test := (testOnly in Test).dependsOn(startDynamoDBLocal).value

应更改为:

testOnly in Test := (testOnly in Test).dependsOn(startDynamoDBLocal).evaluated