« Return to Thread: Code coverage reports - finding name of closure

Re: Code coverage reports - finding name of closure

by MikeHugo :: Rate this Message:

Reply to Author | View in Thread

Thanks for all the ideas!  Burt, your logic did just what I was  
looking for, thanks!

Mike

On Nov 20, 2008, at 9:37 AM, Burt Beckwith wrote:

> You can get the controller class bean (a  
> DefaultGrailsControllerClass) from
> the Spring context and find the properties that are Closures, and  
> map their
> field names to their classes:
>
>   def controllerClass =
> ctx.getBean('com.foo.bar.controller.AccountControllerClass')
>
>   def closures = [:]
>
>   controllerClass.reference.propertyDescriptors.each  
> { propertyDescriptor ->
>     def closure =
> controllerClass
> .getPropertyOrStaticPropertyOrFieldValue(propertyDescriptor.name,
> Closure)
>     if (closure) {
>       closures.put(propertyDescriptor.name, closure.class.name)
>     }
>   }
>
> --
> Burt
>
> On Thursday 20 November 2008 8:59:01 am Mike Hugo wrote:
>> I'm trying to add an enhancement to the code-coverage plugin that
>> would show the name of a closure in the coverage reports.
>>
>> So for instance, right now the reports show:
>> AccountController$_closure1
>> AccountController$_closure2
>> AccountController$_closure3
>> etc...
>>
>> I'd like it to show
>> AccountController.list
>> AccountController.edit
>> AccountController.create
>> etc...
>>
>> Any thoughts on how I could do this?  I'm guessing I will have to do
>> some post processing of the reports, but I'm not positive on how to
>> line up AccountController$_closure1 with AccountController.list
>>
>> This might be a topic for the Groovy list, but I thought I'd start
>> here.  Any ideas?
>>
>> Mike
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Code coverage reports - finding name of closure