SBT doesn't call Test.Setup on a Play2 project

Here is my SBT build:

  val main = play.Project(appName, appVersion, appDependencies).settings(defaultScalaSettings:_*)
    .settings(
    scalaVersion := "2.10.0",
    resolvers += .....
  )
    .configs(IntegrationTest)
    .settings( Defaults.itSettings : _*)
    .settings(
    testOptions in Test += Tests.Setup( () => println("Setup Test yoohooo") ),
    testOptions in Test += Tests.Cleanup( () => println("Cleanup Test yoohoo") ),
    scalaSource in Test <<= baseDirectory / "test/unit",
    parallelExecution in Test := true,

    testOptions in IntegrationTest += Tests.Setup( () => println("Setup Integration Test yoohoo") ),
    testOptions in IntegrationTest += Tests.Cleanup( () => println("Cleanup Integration Test yoohoo") ),
    scalaSource in IntegrationTest <<= baseDirectory / "test/integration",
    parallelExecution in IntegrationTest := false

  )

I can launch both tasks test and it:test, but it only prints the text for the IntegrationTest, and not for the regular Test.

I see that Play2 has some default settings related:

testOptions in Test += Tests.Setup { loader =>
  loader.loadClass("play.api.Logger").getMethod("init", classOf[java.io.File]).invoke(null, new java.io.File("."))
},

testOptions in Test += Tests.Cleanup { loader =>
  loader.loadClass("play.api.Logger").getMethod("shutdown").invoke(null)
},

Isn't my build supposed to override these settings?

By the way, can I call an external library or a test source class in this Setup?

Answers


Maybe this is constraint of sbt.

sbt official documents says

Setup and Cleanup actions are not supported when a group is forked.

https://github.com/sbt/sbt/blob/v0.12.2/src/sphinx/Detailed-Topics/Testing.rst#forking-tests

http://www.scala-sbt.org/0.12.2/docs/Detailed-Topics/Testing.html

fork in Test := true

is default from Play2.1.0

https://github.com/playframework/Play20/pull/654/files#L5L110


Need Your Help


About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.