Details
Description
This was originally reported some time back, as a ticket within the GSPOCK project (GPSPOCK-14); however it was suggested to be reported to Grails core.
Description
The attached project shows how using MockFor within tests - in this case Spock using @TestFor - appears to bleed that mock instance into a subsequent test that is trying to use the actual type unmocked.
jerome@mofo:~/project/bad-mockfor$ grails test-app unit: toplevel.services.MehServiceSpec toplevel.controllers.BahControllerSpec Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 22). | Completed 2 spock tests, 0 failed in 2957ms | Tests PASSED - view reports in target/test-reports
jerome@mofo:~/project/bad-mockfor$ grails test-app unit: toplevel.controllers.BahControllerSpec toplevel.services.MehServiceSpec Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 22). | Running 2 spock tests... 2 of 2 | Failure: it should delegate to other(toplevel.services.MehServiceSpec) | junit.framework.AssertionFailedError: No more calls to 'getName' expected at this point. End of demands. at toplevel.services.MehServiceSpec.it should delegate to other_closure2(MehServiceSpec.groovy:21) at toplevel.services.MehServiceSpec.it should delegate to other(MehServiceSpec.groovy:20) | Completed 2 spock tests, 1 failed in 2864ms | Tests FAILED - view reports in target/test-reports
Meant to also add that this appears to be referenced by this thread
http://grails.1312388.n4.nabble.com/Bad-groovy-MockFor-and-grails-UnitTestMixin-interaction-td4495633.html