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?

Cheers,
Colin

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:

java.lang.NullPointerException
    at com.intellij.openapi.editor.impl.DocumentImpl$MyCharArray.afterChangedUpdate(DocumentImpl.java:793)
    at com.intellij.openapi.editor.impl.CharArray.replace(CharArray.java:66)
    at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:400)


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.

0

Please sign in to leave a comment.