History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: UNI-143
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Tim Ducheyne
Reporter: Brad Cupit
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Unitils

auto unwrap mock

Created: 26/May/09 09:32 PM   Updated: 04/Jun/09 09:56 PM
Component/s: mock
Affects Version/s: 2.0, 2.2
Fix Version/s: 2.3


 Description  « Hide
it would be convenient, and potentially easier to read, if mock objects were automatically 'unwrapped'. This code:
  mockParent.returns(mockChild.getMock()).getChild();
could instead be written as:
  mockParent.returns(mockChild).getChild();

Since code-under-test would never expect an org.unitils.mock.Mock instance, it would be nice if returns() automatically called getMock() for us.

One fast way to implement this: add overloads in MockObject and the Mock interface:

public T returns(Mock<?> mock) {
    return returns(mock.getMock());
}

public T onceReturns(Mock<?> mock) {
    return onceReturns(mock.getMock());
}

 All   Comments   Change History      Sort Order:
Filip Neven - 27/May/09 09:24 AM
This is a very good suggestion, we will certainly do this. Thanks for the feedback.

Brad Cupit - 27/May/09 01:08 PM
yay! I'm looking forward to it. Thanks for the work you do on this great library!

Brad Cupit - 04/Jun/09 09:56 PM
verify fixed in 2.3
thanks guys!