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

Dil*_*nga 6 scala matcher scalatest

我使用的是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
  }
}
Run Code Online (Sandbox Code Playgroud)

奇怪的是,当我扩展时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
Run Code Online (Sandbox Code Playgroud)