Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.0
-
Fix Version/s: 1.7.1
-
Component/s: mocks and stubs
-
Labels:None
-
Environment:groovy 1.0, Java 1.5, Windows 2000
-
Number of attachments :
Description
Would like the ability to stub/mock constructors.
Example:
def dateStub = new StubFor( Date )
dateStub.demand.Date
{ aControlCurrentTime }
Expectation is that .Date would be the default constructor of the Date class.
I have a minor modification to MockFor/StubFor which supports this functionality. Here is an example of usage (mirroring this issue's suggestion):
There is an optional parameter (defaulting to false) for the Constructor which indicates that mocking of the constructor is to be enabled. It is only possible to use with GroovyObjects.