Friday, May 15, 2015

IntelliJ and junit-hierarchicalcontextrunner

For those using junit-hierarchicalcontextrunner getting an exception like
java.lang.Exception: The inner class com.mycompany.SomeClassTest$InnerClass is not static.
 at org.junit.runners.BlockJUnit4ClassRunner.validateNoNonStaticInnerClass(BlockJUnit4ClassRunner.java:113)
...
You might be able to get rid of that error (especially if it happens when running in IntelliJ, but not the commandline) by upgrading to JUnit 4.12 and junit-hierarchicalcontextrunner 4.12.0. However, if you're an IntelliJ user, you'll find that running an individual test still runs all the tests. This will be fixed in an upcoming release.