mockito/mockito — pull request #106 by fluentfuture (2014-10-13 17:16:55+00:00)
Title: Partial

Hi, Here's the implementation of the partial mock support I was talking about:
```
partialMock(Class);
partialMock(Object enclosingInstance, Class innerClass);
```
The second overload is the one solution to the arbitrary constructor parameter issue:
```
@Mock private Collaborator1 mockCollaborator1;
@Mock private Collaborator2 mockCollaborator2;
@PartialMock private MockWorker worker;

abstract class MockWorker extends Worker {
MockWorker() {
super(mockCollaborator1, mockCollaborator2);
}
}
```

I didn't name it spy() for the following reasons:

1. spy() doesn't work for final methods. It would be surprising if user's partial mock works without "final" and stops working when "final" is added. The non-abstract methods aren't meant to be mocked after all.
2. With partial mock, one goal is to allow having state in the object. The shallow copying of spy() won't always work when there is mutable state, especially if there are private methods in the class that spy cannot intercept.
3. "Spy" conceptually needs a target object to spy on. Without a target, spy(Foo.class) feels non-intuitive.
4. All the use cases I know of for partial mocking don't need spying.
5. If really needed, one can always explicitly ```spy(partialMock(Foo.class))```.

Annotation support isn't added yet.