मैं अपने "परीक्षण" और "यह" एसबीटी में विन्यास के बीच एक सहायक विशेषता साझा करना चाहते हैं, लेकिन मैं समझ नहीं कैसे है।"इसे" (एकीकरण परीक्षण) कॉन्फ़िगरेशन में "परीक्षण" कक्षाएं कैसे उपलब्ध कराएं?
यहाँ एक न्यूनतम उदाहरण है:
परियोजना/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> 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
उचित लगता है। धन्यवाद! –
@ यूजीन योकोटा ऐसी कस्टम कॉन्फ़िगरेशन का उपयोग करते समय केवल विशिष्ट टेस्ट सूइट (टेस्ट क्लास) चलाने के लिए दूर है? की कोशिश की 'मज़ा: कोई भाग्य – 3Gee