Using test framework with JUnit 4?

Hi all,

I'd like to use the test framework with JUnit 4 because I'd like to use the parameterised tests feature. Has anyone managed to make this work? I tried converting one of my tests which extends
LightCodeInsightTestCase, but I had a lot of problems with it. I had to call setUp() manually and override getTestName(), but then it complained during configureFromFileText() that write actions can only be run from the dispatch thread. Any suggestions for better ways to do this?


1 comment
Comment actions Permalink

So I got a bit further with this by wrapping the whole test (after calling setUp()) in ApplicationManager.getApplication().invokeLater(), but then it crashes later with an NPE:

    at com.intellij.openapi.editor.impl.DocumentImpl$MyCharArray.afterChangedUpdate(
    at com.intellij.openapi.editor.impl.CharArray.replace(
    at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(

This seems to be that Event.getDocument() for a DocumentEvent is null. Does anyone have any insight into why JUnit 3 and 4 should behave so differently? I'm new to JUnit, I've always used TestNG, so there may be something obvious I'm missing.


Please sign in to leave a comment.