为什么scalatest matcher`不应该包括`不能用FlatSpec编译,而是使用FunSuite

时间:2014-01-21 09:07:59

标签: scala scalatest matcher

我正在使用scala 2.9.3和scalatest_2.9.3-1.9.2。我在使用匹配器断言字符串不包含子字符串时遇到问题:

import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers._

class Learning extends FlatSpec {
  behavior of "..."
  it should "..." in {
    val msg = "Upload successful"
    msg should include ("successful")  // compiles
    msg should not include ("error")   // does not compile
  }
}

奇怪的是,当我扩展org.scalatest.FunSuite时,编译错误消失了。发生了什么事?

报告的编译错误是:

[ant:scalac] Learn.scala: error: value include is not a member of org.scalatest.matchers.ShouldMatchers.ResultOfNotWordForLengthWrapper[java.lang.String]
[ant:scalac]     serialized should not include ("error")
[ant:scalac]                           ^
[ant:scalac] one error found

0 个答案:

没有答案