1

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.

Baptiste Merliot
  • 841
  • 11
  • 24

3 Answers3

3

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

Baptiste Merliot
  • 841
  • 11
  • 24
1

If everything build perfectly and if you can run the tests outside IntelliJ, it may just be an IDE problem.

Try to follow those steps to invalidate cache/restart and tell me if this solve your problem.

Argurth
  • 625
  • 6
  • 18
  • I already tried this, sorry not to have mentioned it. Sadly it does not work for me. [Link to the similar issue](https://stackoverflow.com/questions/39924928/scalatest-v3-why-require-to-implement-converttolegacyequalizer). I prefered creating a new question rather than raising the former from the dead. – Baptiste Merliot Oct 31 '18 at 13:29
  • 1
    No problem, I will try to reproduce it – Argurth Oct 31 '18 at 13:35
  • While trying to reproduce your issue, I found another post about a similar one, have your checked that the JDK is correctly set in Intellij ? (here is [the link](https://stackoverflow.com/questions/45153985/class-must-either-be-declared-abstract-or-implement-converttolegacycheckingequal) as a reference, check the comments of the first answer) I can confirm that everything is working for me (Except a missing "with Matchers" to be able to use the should keyword) – Argurth Oct 31 '18 at 13:48
  • I just checked, IntelliJ's jdk path is set to my JAVA_HOME, and Maven too. – Baptiste Merliot Oct 31 '18 at 14:01
  • My bad for the should keyword, I didn't want to make a too complicated example on Stack Overflow. Edited that. – Baptiste Merliot Oct 31 '18 at 14:02
  • Found a similar error in my maven configuration. Testing if this resolves my problem. – Baptiste Merliot Oct 31 '18 at 14:17
  • This does not work, even after invalidate cache/restart again. – Baptiste Merliot Oct 31 '18 at 14:32
  • No problem for the keyword. I'm suspecting it's a configuration problem as I can't reproduce it. It's even more likely to be that if running the tests from the command line is indeed working. I would be curious to know what was the problem once you solve it. – Argurth Oct 31 '18 at 14:41
0

I had to delete old version of scalatests from Library. ProjectStructure->libraries->[locate scalatest 0.9 ...] - delete

miroB
  • 468
  • 6
  • 8