This had happened before, but it got me again the other day: I was using Unitils‘ mock annotations (great stuff!) to set up my mocks, but my test failed with a NullPointerException the first place I tried to set an expection on the mock. The reason being… I forgot to @RunWith(UnitilsJUnit4TestClassRunner.class) . Sadly, I don’t think I was much faster diagnosing the problem this time than I was last time.
Goal: Next time this symptom appears, instantly suspect that I’m using the wrong runner! :)