Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0
-
Fix Version/s: 1.7.1
-
Component/s: mocks and stubs
-
Labels:None
-
Testcase included:yes
-
Patch Submitted:Yes
-
Number of attachments :
Description
Half-Mocks are mocks for classes with dynamic methods or properties. One example are Grails domain objects where you would use the implemented domain specific methods but want to mock the GORM methods.
Issue Links
- is depended upon by
-
GROOVY-4026
MockFor and StubFor improvements
-
OK, I now have a patch (borrowing from Stefan's patch and also the recent ignore amendments) which supports a form of half-mocks. It needs further testing and doco before committing to trunk but to give a flavor:
Basically, all method calls must match according to the appropriate expectation unless explicitly ignored. When ignoring, a closure can be provided to return a value (much like a demand return result) but the call won't be included when comparing with expected calls. If the ignore method has no return closure, then it defaults through to calling the original underlying instance.