hprange / wounit

The WOUnit framework contains a set of utilities for testing WebObjects applications using JUnit 4.7 or later capabilities.
http://hprange.github.io/wounit/
Apache License 2.0
19 stars 18 forks source link

Support spied objects with Mockito #22

Closed hprange closed 12 years ago

hprange commented 12 years ago

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()); 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.

IMPORTANT: Mockito must not be a requirement for people in order to make use of WOUnit.