jtanistra / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

org.spockframework.mock.CannotCreateMockException: Cannot create mock for class com.example.MyClassnull #300

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem? If possible, provide source code and
stack trace.
1. Checkout project at https://github.com/salvadordiaz/spock-bug
2. Follow instructions in README.md

What version of Spock and Groovy are you using?
spock-0.7 groovy 1.8.6

The bug only happens the second time the test is run in the same interactive 
grails session

Original issue reported on code.google.com by diaz.sal...@gmail.com on 19 Feb 2013 at 10:39

GoogleCodeExporter commented 8 years ago
I don't know enough about how interactive Grails sessions work. Do they have 
known limitations, for example regarding class loading?

Original comment by pnied...@gmail.com on 17 Mar 2013 at 7:49

GoogleCodeExporter commented 8 years ago
I have seen this problem in some code at work when I tried to move from Spock 
0.5 to 0.7 today. 

All/most of the Mock() calls are returning the same ClassCastException you 
reported. I see this when I run a test suite in IntelliJ though. I haven't 
tracked down if the first use of Mock() in the suite succeeds and all the rest 
fail but if so that would probably be similar to what you are reporting.

Original comment by joshua.s...@gmail.com on 21 Mar 2013 at 8:33

GoogleCodeExporter commented 8 years ago
Is it possible that the "Splitting up Class Specification" is burning us here?
http://docs.spockframework.org/en/spock-0.7-groovy-2.0/new_and_noteworthy.html#s
plitting-up-class-specification

Original comment by joshua.s...@gmail.com on 21 Mar 2013 at 8:38

GoogleCodeExporter commented 8 years ago
Make sure you do a full rebuild after upgrading Spock, as documented in the 
migration notes.

Original comment by pnied...@gmail.com on 21 Mar 2013 at 11:21

GoogleCodeExporter commented 8 years ago
Well, the bug is reproductible with a brand new, freshly created project ( the 
one referenced in this report : https://github.com/salvadordiaz/spock-bug ) so 
there was no spock upgrade in it and it still exhibits this bug.

Anyway, in my real project I checked out a new copy of the code and did a 
grails clean and even then I was able to reproduce the bug.

Original comment by diaz.sal...@gmail.com on 22 Mar 2013 at 9:17

GoogleCodeExporter commented 8 years ago
I agree, I have done a full rebuild a number of times and it has not resolved 
the issue.

Original comment by joshua.s...@gmail.com on 22 Mar 2013 at 1:16

GoogleCodeExporter commented 8 years ago

Original comment by pnied...@gmail.com on 10 Apr 2013 at 6:16