私はSBTの私の "テスト"と "それ"の設定の間でヘルパーの特性を共有したいと思いますが、私はどのように考え出していません。ここで"it"(統合テスト)設定で "テスト"クラスを使用できるようにするにはどうすればよいですか?
は、最小限の例です。
プロジェクト/ Build.scala
import sbt._
import Keys._
object MyBuild extends Build {
val scalaTest = "org.scalatest" %% "scalatest" % "2.0" % "test,it"
lazy val myProject =
Project(id = "my-project", base = file("."))
.configs(IntegrationTest)
.settings(Defaults.itSettings: _*)
.settings(
scalaVersion := "2.10.3",
libraryDependencies ++= Seq(
scalaTest
)
)
}
のsrc /テスト/スカラ座/ Helpers.scala
trait Helper {
def help() { println("helping.") }
}
のsrc /テスト/scala/TestSuite.scala
import org.scalatest._
class TestSuite extends FlatSpec with Matchers with Helper {
"My code" should "work" in {
help()
true should be(true)
}
}
のsrc /それ/スカラ座/ ItSuite.scala
import org.scalatest._
class ItSuite extends FlatSpec with Matchers with Helper {
"My code" should "work" in {
help()
true should be(true)
}
}
、その後、SBTで、 "テストは" 作品:
sbt> test
helping.
[info] TestSuite:
[info] My code
[info] - should work
[info] Run completed in 223 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 0 s, completed Dec 17, 2013 1:54:56 AM
が、 "それを:テストはありません"コンパイル:
sbt> it:test
[info] Compiling 1 Scala source to ./target/scala-2.10/it-classes...
[error] ./src/it/scala/ItSuite.scala:3: not found: type Helper
[error] class ItSuite extends FlatSpec with Matchers with Helper {
[error] ^
[error] ./src/it/scala/ItSuite.scala:5: not found: value help
[error] help()
[error] ^
[error] two errors found
[error] (it:compile) Compilation failed
[error] Total time: 1 s, completed Dec 17, 2013 1:55:00 AM
と思われます。ありがとう! –
@Eugene Yokotaこのようなカスタム設定を使用する場合、特定のTestSuite(テストクラス)のみを実行することはありますか?試した 'fun:testOnly * MySpecialSuit'で運がない場合 – 3Gee