Search code examples
scalaintellij-ideascalatest

IntelliJ in Scala asking to implement abstract members in a class inheriting from a concrete class


I am trying to implement tests with scalatest 3.0.5. I created my abstract class defining my setup and my first concrete test class, as suggested on the official website.

abstract class TestSpec extends FunSuite

class MyFirstTest extends TestSpec {

    test("This is a test") {assert(1 == 1)}

}

But then Intellij shows the following error :

MyFirstTest must either be declared abstract or implement abstract member 'getTestNameForReport(s:String):String' in 'org.scalatest.Suite'

After reading source code, FunSuite is a concrete class.

I tried changing scalatest version to 2.2.6, but the same problem occures. I tried to implement the abstract members but IntelliJ asks to override some methods like execute, so this does not seem to be a great idea.

For the records, I am using Maven to build my project, and it builds perfectly. The problem is that I cannot run my tests from the IDE as a warning is displayed.


Solution

  • I ended up solving my problem by deleting my project and creating a new one from this archetype with maven. I think my problem was because I messed up my pom somehow.

    If you encounter a similar issue, here are some possible fixes (thanks to @Argurth):

    • invalidate cache/restart following those steps (link to a similar issue)
    • check if the JDK is correctly settled in IntelliJ following steps linked here (see comments in the first answer).
    • Set maven's JDK to your JAVA_HOME. (See the screenshot below, it can be obtained in IntelliJ with File > Setting)

    Maven JDK setting