Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7.0
-
Fix Version/s: 1.7.1, 1.8-beta-1
-
Component/s: mocks and stubs
-
Labels:None
-
Patch Submitted:Yes
Description
MockFor and StubFor provide powerful features for mocking but it would be good to have some additional convenience methods and enhancements.
- Proposed number of times feature:
mock.demand.hasNext(3) { true }as shorthand for:
mock.demand.hasNext(3..3) { true }
- Proposed ignore feature supports code fragments like:
def mock = new MockFor(AlphaIterator) def expectedCount = 2 mock.ignore('next'){ /* ignored */ } mock.demand.hasNext(expectedCount){ true } mock.demand.hasNext{ false } mock.use { assert new IteratorCounter().count(new AlphaIterator()) == expectedCount }
Issue Links
- depends upon
-
GROOVY-2630
Support Half-Mocks
-
- supercedes
-
GROOVY-1871
New MockFor support for properties means not possible to mock just methods
-
-
GROOVY-1864
MockFor property support requires "demands" for all property access
-
proposed patch attached