ScalaTest v3: why require to implement convertToLegacyEqualizer

纵饮孤独 提交于 2019-12-08 15:50:02

问题


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?


回答1:


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




回答2:


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:

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.




回答3:


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.



来源:https://stackoverflow.com/questions/39924928/scalatest-v3-why-require-to-implement-converttolegacyequalizer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!