hprange/wounit — Issue #22: Support spied objects with Mockito
Author: hprange
Created: 2011-10-20 01:53:45+00:00
State: open

Mockito is a really nice and useful Mock framework and it has a powerful implementation of test spies. Spied objects can be partially stubbed, without changing the overall behavior of the object. Spying EOs requires a couple of boilerplate code and the WOUnit annotations cannot be used:

@Test
public void testSomething() {
Foo foo = Mockito.spy(new Foo());
foo = ec.insertSavedObject(foo);
}

We could offer a better option:

@Spy @Dummy
private Foo foo;

I have to check if the @Spy annotation from Mockito will play nice in this scenario. Otherwise, the WOUnit can provide a different annotation (@Spied maybe) to avoid naming clash.