Friday, April 30, 2010

Cannot invoke method containsKey() on null object

I spent about an hour on this one today.  I have a Grails Integration test with mock objects, but every time I tried to instantiate the Mock (via mockFor(MyService) ) I was receiving the error :

Cannot invoke method containsKey() on null object

After toying with it for too long I googled it up and found that I had forgotten the super.setUp() in my setUp() method. After correcting that :

  protected void setUp() {
    super.setUp()
...

All was well. Ugh..

No comments: