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


#1

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


#2

Unfortunately we can’t help you if you don’t provide any information about the details of your problem. http://stackoverflow.com/help/how-to-ask is a great introduction to asking technical questions in a way that makes it easy for others to answer them.


#3
  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.

#4

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?


#5

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:


#6

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


#7

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


#8

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.


#9

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