Re: Mocking classes with final mehtods

344 views
Skip to first unread message

Peter Niederwieser

unread,
Feb 19, 2013, 12:32:10 PM2/19/13
to spockfr...@googlegroups.com
CGLIB-based mocks can mock neither final classes nor final methods (no matter which mocking framework is used). If the code under specification is written in Groovy, Spock allows you to mock final classes/methods with `GroovyMock`. See http://docs.spockframework.org for the details.

Cheers,
Peter

On Feb 19, 2013, at 6:13 PM, Przemysław Jakubczyk <przemyslaw...@polidea.pl> wrote:

I've just got a funny thing. I was doing a refactor my Android project using RoboSpock (https://github.com/Polidea/RoboSpock) and wanted to Mock some object in order to have a really good unit test I got the wall why I could't make mock to check if a method was invoked. 

After an hour of looking what is going on I realized that Spock is based on cglib so it can't mock final class (we all know this) but also doesn't allow to mock final methods...

Hope I helped.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spockframewor...@googlegroups.com.
To post to this group, send email to spockfr...@googlegroups.com.
Visit this group at http://groups.google.com/group/spockframework?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Przemysław Jakubczyk

unread,
Feb 20, 2013, 4:31:01 AM2/20/13
to spockfr...@googlegroups.com
Thanks for fast replay. Production code is Java, but anyway thanks for help!
Reply all
Reply to author
Forward
0 new messages