私は build.sbt を使用しています。これはクロス コンパイル設定があり、基本的には " Play with scala-js example " の適応バージョンであり、テスト用のクリーンなセットアップを取得するのに問題があります。具体的には、サーバー テストを実行すると、クライアント テストも実行されます (これは避けたいことです)。
uTest を取得してテストを表示できないの指示に従い、 追加しました
libraryDependencies += "com.lihaoyi" %%% "utest" % "0.3.0"
何らかの理由で、追加するまでテストが実行されませんでした
testFrameworks += new TestFramework("utest.runner.Framework")
すべてのプロジェクト定義に。また追加しない
"com.lihaoyi" %% "utest" % "0.3.1" % "テスト"
サーバー側への一連のトリガー
見つかりません: オブジェクト utest [エラー] インポート utest._ -スタイル エラー。
私の印象では、クリーンなセットアップがあれば、これらの追加設定をまったく追加する必要はありません。これが私のsbtファイルです:
import sbt.Project.projectToRef
lazy val clients = Seq(client)
lazy val scalaV = "2.11.7"
lazy val server = (project in file("server")).settings(
scalaVersion := scalaV,
scalaJSProjects := clients,
pipelineStages := Seq(scalaJSProd/*, gzip*/),
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
libraryDependencies ++= Seq(
"com.vmunier" %% "play-scalajs-scripts" % "0.3.0",
"be.doeraene" %% "scalajs-pickling-play-json" % "0.4.0"
),
testFrameworks += new TestFramework("utest.runner.Framework")
).enablePlugins(PlayScala).
aggregate(clients.map(projectToRef): _*).
dependsOn(sharedJvm)
lazy val client = (project in file("client")).settings(
scalaVersion := scalaV,
persistLauncher := true,
persistLauncher in Test := false,
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.8.0"
),
testFrameworks += new TestFramework("utest.runner.Framework")
).enablePlugins(ScalaJSPlugin, ScalaJSPlay).
dependsOn(sharedJs)
lazy val shared = (crossProject.crossType(CrossType.Pure) in file("shared")).
settings(scalaVersion := scalaV,
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "utest" % "0.3.1",
"be.doeraene" %%% "scalajs-pickling-core" % "0.4.0",
"com.lihaoyi" %%% "pprint" % "0.3.6"
),
testFrameworks += new TestFramework("utest.runner.Framework")
).
jsConfigure(_ enablePlugins ScalaJSPlay)
lazy val sharedJvm = shared.jvm
lazy val sharedJs = shared.js
// loads the Play project at sbt startup
onLoad in Global := (Command.process("project server", _: State)) compose (onLoad in Global).value
そして、ここに私の問題の要約があります:
- クライアント/テストを実行すると、クライアント テストのみが実行されます
- play-with-scalajs-example/test を実行すると、クライアント + 共有テストが実行されます
- 奇妙なことに、サーバー/テストを実行すると、サーバーとクライアントのテストが実行されます
プロジェクト設定を次のように変更するにはどうすればよいですか
- server/test の実行時にサーバー テストを見つける
- play-with-scalajs-example/test の実行時にすべてのテストを実行する
- さらに、サーバー/テストまたはクライアント テストを実行するときに共有テストを含めますか?
また、別のノードで、scalatest を無効にする方法はありますか? それはかなり読みにくいテスト出力につながります:
[info] 1/2 TestSimpleServerSuite.absolutely simple test on the server side Success
[info] 2/2 TestSimpleServerSuite Success
[info] utest
[info] -----------------------------------Results-----------------------------------
[info]
[info]
[info] Tests: 0
[info] Passed: 0
[info] Failed: 0
[info] Passed: Total 2, Failed 0, Errors 0, Passed 2
[info] 1/2 TestSimpleClientSuite.absolutely simple test on the client side Success
[info] 2/2 TestSimpleClientSuite Success
[info] 1/2 SimpleClient.TestSimpleClientSuite.absolutely simple test on the client side Success
[info] 2/2 SimpleClient.TestSimpleClientSuite Success
[info] ScalaCheck
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] ScalaTest
[info] Run completed in 1 second, 751 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] utest
[info] -----------------------------------Results-----------------------------------
[info] SimpleClient.TestSimpleClientSuite Success
[info] absolutely simple test on the client side Success
[info] TestSimpleClientSuite Success
[info] absolutely simple test on the client side Success
[info]
[info] Tests: 4
[info] Passed: 4
[info] Failed: 0
[info] Passed: Total 4, Failed 0, Errors 0, Passed 4
[success] Total time: 11 s, completed 16.10.2015 03:25:59
どうもありがとうございました。