Grails unit testing and bootstrap

Posted by tbruyelle on Stack Overflow See other posts from Stack Overflow or by tbruyelle
Published on 2012-10-11T08:26:30Z Indexed on 2012/10/11 9:37 UTC
Read the original article Hit count: 143

Filed under:
|

I wrote an unit test for a controller.

I have a Bootstrap file which alter the metaclass of domain classes by adding a method asPublicMap(). I use this method in the controller to return domain classes as json but only some selected public fields.

My unit test failed because of MissingMethodException for asPublicMap(). As I understood, bootstrap classes are not loaded for unit tests, only for integration tests. That's why I got this error.

My question is : Is there another place to put metaclass manipulation in order to take them into account during unit tests ?

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about grails