3

我收到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
    }
  }
}
4

1 回答 1

5

must 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 prop { (a:Int) => 
      true
    }
    "with a custom generator" in {
      Prop.forAll(smallInteger) { i: Int =>
        true
      }
    }
  }
}
于 2013-06-20T07:26:18.963 回答