0
我有一个使用maven的eclipse scala项目。安装了ScalaIDE和Scalatest的Eclipse插件。我有这样的测试:Scalatest在使用Matcher时显示错误
import org.scalatest._
class ExampleSpec extends FlatSpec with Matchers {
feature("Feature A Test") {
scenario("Foo scenario 1") {
val a = FooClass().getResult()
a.count shouldBe 1 // IDE shows error: value shouldBe is not a member of Long
a(0).getString(0) shouldBe "FOO" // IDE shows error: value shouldBe is not a member of String
}
}
}
Maven的编译和测试运行正常,但在Eclipse,当我打开这个文件,我看到日食的错误无论我使用的是Matcher
如上在评论中提到。例如。
value shouldBe is not a member of Long
我在想什么?一个scala测试文件显示了数百个问题。
您是如何将项目导入IDE的?在“Java Build Path” - >“Libraries” - >“Maven容器(或其他名称)”中可以看到scalatest? “Scala编译器” - >“Scala安装”中的Scala版本与POM中声明的版本相同吗? – MirMasej
它确实出现在“Java构建路径 - 库 - maven依赖关系 - scalatest”下。是的,Scala版本在这两个地方都是一样的。 – rgamber
你有没有[在匹配器中混合](http://www.scalatest.org/user_guide/using_matchers)在Spec? – MirMasej