16
votes

Using ScalaTest 3.0.0 Environment: Scala 2.11.8, sbt 0.13.5, IntelliJ 14.1.4

build.sbt has only

// NOTE: not using org.scalactic
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"

The test below passed. However, IntelliJ marks a squiggly red line below MyMiniTest with the warning message:

Class 'MyMiniTest ' must either be declared abstract or implement abstract member 'convertToLegacyEqualizer[T](left: T): TripleEqualsSupport.this.LegacyEqualizer[T]' in 'org.scalactic.TripleEqualsSupport'

import org.scalatest.FeatureSpec

class MyMiniTest extends FeatureSpec {
  scenario("A simple test") {
    val a = 12
    assert(a * 3 == 36)
  }
}

What is the reason of this warning and what is the recommended solution to fix it?

3

3 Answers

6
votes

I had the same problem on IntelliJ just follow this steps to invalidate cache/restart. This will solve the problem.

2
votes

In my case it was a transitive dependency (don't know how a test library could appear as such) of a different version clashing with the dependency defined in my project. SBT knows how to deal with most of these cases, IntelliJ doesn't seem to know. Note that invalidating the cache and restarting IntelliJ wouldn't help in this case.

To be sure it's your case, check the following: File -> Project Structure -> [Project Settings - Libraries]. Look for org.scalatest:* and you will probably find two libraries, like this: enter image description here

Then remove the unnecessary one by selecting it and pressing - at the top of the panel. That's it, IntelliJ will be happy now.

A cleaner solution would be to exclude the unnecessary library from your dependencies, e.g.: ExclusionRule("org.scalatest", "scalatest_2.11-2.2.4")

IntelliJ will show the library among the project's dependencies, but will know that it should be ingored.

0
votes

Please check all you dependencies and check if any of those dependencies is downloading org.scalatest.* . If the version of org.scalatest.* you have defined is different from the one getting downloaded due to other defined dependencies, this issue occurs. I was using org.mockito%mockito-scala whose pom defined that scalatest 3.0.8 was provided. But the scalatest I had defined was 2.2.5. By changing the version of scalatest to 3.0.8, I was able to resolve this issue.

Hope this helps.