Specs2和scalacheck - 必须通过问题

时间:2013-06-20 07:05:46

标签: scala specs2 scalacheck

我在下面的代码段中收到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
    }
  }
}

1 个答案:

答案 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
      }
    }
  }
}