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