Thursday, July 8, 2010

Yeast Infection Cancelhysterectomy

tiny detail when using annotations in TagLibUnitTestCase

This is a quick tip when using TagLibUnitTestCase, and infer that serves to invoke classes using mocks and also be tested by invoking closures.

TagLibUnitTestCase Using a taglib is variable, and as such is the instance of the class you are testing, in my case I use some units that use my library of tags and injected by hand, but by invoking the code as follows:

 
tagLib.dojoField (
[bean: tax, field: "totalImpuestosRetenidos"
useLabelTemplate: true], null)


But the unit test failed, sent NullPointerException, curiously to invoke any method dependencies, to perform various tests I realized that when you invoke the closure of That way, you created a new instance of taglib, of course, without the dependencies that had been injected previously.

To avoid falling into that mistake, we just have to invoke the closure as "java", using the call () method of closure:

 
tagLib.dojoField.call (
[bean: tax,
field: "totalImpuestosRetenidos"
useLabelTemplate: true], null)


And in this way will not have this strange behavior.

worth mentioning that I tested on Grails 1.3.2

0 comments:

Post a Comment