scala不会发现'应该'的功能

Kil*_*yte 3 scala scalatest

我有这个代码用于测试:

import org.scalatest.FlatSpec
import org.scalatest.matchers.Matchers

class TestSpec extends FlatSpec with Matchers {
  "something" should "be something else" in {
    "test" should be ("test")
  }
}
Run Code Online (Sandbox Code Playgroud)

但是我得到这个错误:

Error:(21, 12) overloaded method value should with alternatives:
  (resultOfAfterWordApplication: org.scalatest.verb.ResultOfAfterWordApplication)(implicit fun: (String, String, org.scalatest.verb.ResultOfAfterWordApplication) => Unit)Unit <and>
  (right: => Unit)(implicit fun: org.scalatest.verb.StringVerbBlockRegistration)Unit <and>
  (right: org.scalatest.verb.BehaveWord)(implicit fun: String => org.scalatest.verb.BehaveWord)org.scalatest.verb.BehaveWord <and>
  (right: String)(implicit fun: (String, String, String) => org.scalatest.verb.ResultOfStringPassedToVerb)org.scalatest.verb.ResultOfStringPassedToVerb
 cannot be applied to (org.scalatest.matchers.Matcher[Any])
    "test" should be ("test")
           ^
Run Code Online (Sandbox Code Playgroud)

我正在从他们的网站直接获取代码,并通过maven描述符org.scalatest安装ScalaTest:scalatest_2.10.0:2.0.M5现在似乎是最新的

小智 5

尝试执行以下操作:

import org.scalatest.matchers.ShouldMatchers

class TestSpec extends FlatSpec with ShouldMatchers
Run Code Online (Sandbox Code Playgroud)