Reputation: 11020
How to do the equivalent of Mockito's deep mock / stub (RETURNS_DEEP_STUBS ) in Spock? Something like:
Changes changes = Mock()
changes.id(_).current() >> aChangeApi
While in Mockito it'd be:
Changes changes = mock(Changes.class, RETURNS_DEEP_STUBS);
when(changes.id(any()).current()).thenReturn(aChangeApi);
Upvotes: 8
Views: 2440
Reputation: 478
I think you can do something like:
Changes changes = Stub()
changes.id(_) >> Stub(<ReturnedClass>) {
current() >> aChangeApi
}
This just returns a stub which can then be further mocked. I'm not that familiar with Mockito but from a bit of google searching this seems to be the way that should get a similar result.
Upvotes: 6