我在下面的代码段中收到not found: value pass
错误
我是否会错过任何导入或此代码对 specs2 无效?
import org.specs2.mutable.Specification
import org.specs2.ScalaCheck
import org.scalacheck.{Prop, Gen}
class TestSpec extends Specification with ScalaCheck {
"Calling test spec" should {
"always pass" in {
val prop = Prop.forAll((a:Int) => true)
prop must pass
}
}
}
答案 0 :(得分:5)
must pass
是原始specs项目中使用的内容。使用specs2,您只需编写:
import org.specs2.mutable.Specification
import org.specs2.ScalaCheck
import org.scalacheck.{Prop, Gen}
class TestSpec extends Specification with ScalaCheck {
"Calling test spec" should {
"always pass" in prop { (a:Int) =>
true
}
"with a custom generator" in {
Prop.forAll(smallInteger) { i: Int =>
true
}
}
}
}