Search code examples
intellij-ideagroovyjunitjunit4

How to configure IntelliJ for running test with JUnit 4?


Should be simple but I couldn't figure it out.

When running my unit test inside IntelliJ, I could not find a way to tell IntelliJ-9.0 that it should use JUnit4 instead of JUnit3.

When a test fails, IntelliJ console displays:

MyTests.testConstraints(MyTests.groovy:20) at

...

com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:108) at com.intellij.junit3.JUnit3IdeaTestRunner.startRunnerWithArgs(JUnit3IdeaTestRunner.java:42) ...

Do you know how to replace JUnit3 by JUnit4 ?


Solution

  • I found it!

    1. Go to Run/Debug Configurations
    2. Add new configuration and choose a JUnit
    3. In the configuration tab, add "-junit4" to the Test run parameters input field

    And that's done !