Domanda

I configured the Play Framework 2.0 to use SCCT for coverage, and can run scct using play scct:cover.

However, my tests are unable to read any configuration files, because the configuration files are not in the classpath. To wit, I am using the typesafe ConfigFactory to load the configuration files, and I receive the following error: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'KEY.NAME'

play test and play run work perfectly well.

Is there some way I can force Play's Build.scala to add the conf/ directory to the classpath?

The relevant portion of my plugins.sbt file looks like this: 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")

The relevant portion of my Build.scala looks like this: 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
)

Thanks!

È stato utile?

Soluzione

This is probably not specific to Play. The scct plugin should probably include the resources in the Test configuration in the ScctTest configuration like it does for other classpath elements. You can do it yourself explicitly by adding the conf directory to the list of unmanaged resource directories for scct:

unmanagedResourceDirectories in ScctPlugin.ScctTest <+= baseDirectory( _ / "conf")

Altri suggerimenti

Mark's solution is correct, however it took me a while to put his code in the right place. For anyone else struggling with this, the code should look as follows:

val main = play.Project(appName, appVersion, appDependencies, settings = scct_settings).settings(
    ...
    unmanagedResourceDirectories in ScctPlugin.ScctTest <+= baseDirectory ( _ / "conf")
    ...
)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top