Wednesday, November 5, 2014

JSON converter is not working in unit tests in Grails

If calling grails.converters.JSON from unit test throws error like:

java.lang.RuntimeException: org.codehaus.groovy.grails.web.converters.exceptions.ConverterException: Unconvertable Object of class:
	at org.codehaus.groovy.grails.web.converters.AbstractConverter.toString(
	at org.codehaus.groovy.runtime.InvokerHelper.format(
	at org.codehaus.groovy.runtime.InvokerHelper.format(

It is easy to fix this error by adding ControllerUnitTestMixin to the test definition like:

class BlogServiceTests {

No comments:

Post a Comment