我将 Play Framework 2.0 配置为使用 SCCT 进行覆盖,并且可以使用play scct:cover
.
但是,我的测试无法读取任何配置文件,因为配置文件不在类路径中。也就是说,我使用类型安全的 ConfigFactory 来加载配置文件,我收到以下错误:
com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'KEY.NAME'
play test
并且play run
工作得很好。
有什么方法可以强制 Play 的 Build.scala 将conf/
目录添加到类路径中?
我的 plugins.sbt 文件的相关部分如下所示:
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += Classpaths.typesafeResolver
resolvers += "scct-github-repository" at "http://mtkopone.github.com/scct/maven-repo"
addSbtPlugin("reaktor" % "sbt-scct" % "0.2-SNAPSHOT")
addSbtPlugin("play" % "sbt-plugin" % "2.0.4")
我的 Build.scala 的相关部分如下所示:
lazy val additionalSettings = Defaults.defaultSettings ++ seq(ScctPlugin.instrumentSettings: _*)
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA, settings = additionalSettings).settings(
testOptions in Test := Nil,
parallelExecution in test := false
)
谢谢!