1

これが私の SBT ビルドです。

  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

  )

タスクtestit:testの両方を起動できますが、通常のテストではなく、IntegrationTest のテキストのみが出力されます。

Play2 には関連するデフォルト設定がいくつかあることがわかります。

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)
},

私のビルドはこれらの設定をオーバーライドすることになっていませんか?

ところで、この Setup で外部ライブラリやテスト ソース クラスを呼び出すことはできますか?

4

1 に答える 1

2

多分これはsbtの制約です。

sbtの公式文書によると

グループがフォークされている場合、セットアップおよびクリーンアップ アクションはサポートされません。

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

テストでフォーク:= true

Play2.1.0からのデフォルトです

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

于 2013-05-04T02:21:04.160 に答える