我正在使用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