Grails Testing Plugin often occurred exception

 

by Taras Matyashovsky

 

In previous posts (service unit testing and domain entity unit testing) I told You a lot about Grails Testing Plugin, its simple usage, but have not paid necessary accent on one often occurred exception:

"Cannot invoke method containsKey() on null

object" type="java.lang.NullPointerException"

 

It happens then You override setUp() method but forget to call super method at first. So instead of writing:

 

class SomeTests extends GrailsUnitTestCase {

 

   void setUp() {

       // Some initializations.

   }

 

}

 

Call super method at first:

 

class SomeTests extends GrailsUnitTestCase {

 

    void setUp() {

 

        // Call super method at first.

        super.setUp()

 

 

        // Some initializations.

    }

 

}

 

That's all.

 
 
 

Comments  

 
0 # test 2009-12-03 03:07 hi Reply | Reply with quote | Quote
 
 
0 # test 2009-12-03 03:10 good Reply | Reply with quote | Quote
 

Add comment


Security code
Refresh