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 ?
Press ⌥⏎, or Alt+Enter, in the class name and IntelliJ IDEA offers to migrate the test class to JUnit 5. The refactoring preview window will show the places where changes will be made, in this case a number of annotations will be changed to the new JUnit 5 annotations.
Add a new test In your production code in the editor, place the caret at the class for which you want to create a test, press Alt+Enter , and select Create Test. In the Create Test dialog, select the library that you want to use. If you don't have the necessary library yet, you will be prompted to download it.
I found it!
And that's done !
You can annotate your test class with an annotation to indicate junit the runner it will use
@RunWith(JUnit4.class) MyTestClass {}
I tried to put:
@RunWith(JUnit4.class)
at the beginning of a test.
IntelliJ complained about this, but asked to 'load' JUnit4.class.
So I deleted @RunWith(JUnit4.class)
.
But the 'loading' seems to have fixed the problem - @Ignore
is now respected!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With