斯卡拉不会发现'应该'功能

时间:2014-12-09 16:38:39

标签: 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")
  }
}

但是我收到了这个错误:

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")
           ^

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

1 个答案:

答案 0 :(得分:5)

尝试执行以下操作:

import org.scalatest.matchers.ShouldMatchers

class TestSpec extends FlatSpec with ShouldMatchers