2

I have a project configured with scalatest that I am running in Eclipse Mars 2. I have Scala IDE installed and all is well. I am able to run Scala tests correctly, however I have a very annoying issue. All of my uses of "should", "shouldBe", etc. are marked as syntax errors with "value should is not a member of... " (String, Int, etc.).

My base class extends WordSpecLike with Matchers. As far as I understand from this post scalatest "A stack" should "do something" -- wtf? How is should a method of string? there should be an implicit conversation happening from the various types (or at least from String) to the wrapper that defines the "should" method. It appears that the implicit conversation is not happening? However, tests run just fine, so I am confused.

Any help would be appreciated.

Relevant code fragments below. Both instances of "should" and "shouldBe" are marked as syntax errors (respectively not a member of String and Int).

import org.scalatest._

abstract class CommonUnitTest extends WordSpecLike with Matchers

abstract class CassandraSparkTest extends CommonUnitTest with BeforeAndAfterEach with BeforeAndAfterAll

class DocumentScopeAggregationJobTest extends CassandraSparkTest {
  "DocumentScopeAggregationJob" should {
    "create a running step from DocumentScope table" in {
      ...
      val steps = runningScope.steps
      steps.size shouldBe 1
    }
  }
}
Captain Franz
  • 956
  • 2
  • 9
  • 13
  • We need to see your code. `should` is available in two contexts, the `FlatSpec` defines `should` to specify a particular test, while `Matchers` defines `should` as an assertion. – Bob Dalgleish Aug 11 '17 at 23:12
  • Both are marked as syntax errors. Added relevant code snippet. – Captain Franz Aug 11 '17 at 23:41
  • 1
    If the Scala compiler is not complaining then it's most likely an issue in the presentation compiler (which scala-ide uses to provide error reporting etc) . In general I recommend running the actual compiler (using SBT's incremental compilation) side-by-side your IDE if you are using IntelliJ or Eclipse as the IDEs sometimes disagree with the actual Scala compiler – Jacob Wang Aug 12 '17 at 07:34
  • 1
    check the package of matchers. – digitebs Dec 01 '20 at 09:29
  • 1
    Thanks @digitebs I was using mustBe as matcher but then I decided to use shouldBe and it stop compiling, your comment gave me the hint I was looking for – Capitan Empanada Aug 19 '21 at 09:45

0 Answers0