Have a error "! JUnit version 3.8 or later expected:"

Can’t run kotlin file in IDEA and can’t beat that error.

Unfortunately we can’t help you if you don’t provide any information about the details of your problem. How do I ask a good question? - Help Center - Stack Overflow is a great introduction to asking technical questions in a way that makes it easy for others to answer them.

  1. Download and install IntelliJ IDEA
  2. Create any Kotlin file with “fun main(args: Array)” method
  3. Run it and you’ll figure that error.

As you can imagine, I’ve done this quite a few times and I haven’t seen the error. Could you please attach a screenshot, at least?

Create new project:

Create java class:

Convert it to Kotlin:

Run the file:

Got an error:

Open dialog “run/debug configuration”, figure JUnit test:

Remove it, save dialog:

second run, same error, JUnit test self-restore, like never deleted:

1 Like

What IDEA run:
“C:\Program Files\Java\jdk1.8.0_121\bin\java” -ea -Didea.test.cyclic.buffer.size=1048576 “-javaagent:C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\lib\idea_rt.jar=53650:C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\bin” -Dfile.encoding=UTF-8 -classpath “C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\lib\idea_rt.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\plugins\junit\lib\junit-rt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\rt.jar;C:\Users\JavaD\Desktop\JavaErrorTest\out\production\JavaErrorTest;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\plugins\Kotlin\kotlinc\lib\kotlin-runtime.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\plugins\Kotlin\kotlinc\lib\kotlin-reflect.jar” com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 JavaErrorTest

1 Like

Looks like Idea thinks this is a JUnit test because the class name ends with “Test”. You should probably avoid that.

1 Like

There is indeed a long-standing bug in IntelliJ IDEA that causes the class to be incorrectly detected as a JUnit test in this scenario. The name of the class doesn’t matter. We’ll fix the bug in a future update. To run your code, instead of right-clicking the editor tab, right-click the “main” method and select “Run”, or use the gutter icon to run it.

1 Like

excellent - thx!!!
took me a bit to figure that out

I know this is a very old topic, but I just wanted to say that it appears the name is actually very much making a difference. My test was called AppNameTest before and I renamed it to SomeThingInstrumentedTest, and it immediately moved it under Android Instrumented Tests group in config, and I stopped having the JUnit version error.