Monday, 15 August 2011

Testing the .json response of a regular Grails controller -


I'm trying to run unit tests on my controllers, but '. Testing for JSN results, not only regular results For example, instead of user / index, I want to test user / index.json result.

Thank you.

If your controller assigns a value to JSON < / Code>, you can use this value in the controller SEPC controller .response.json.valueYouWantToAccess

For example if the return value

   

Then your controller SEPEC

<[codec: 1, status message: message (code: "success.message", default: success " In / code> you can use it like this:

  Controller. Json.statusMessage  

No comments:

Post a Comment