Wednesday, 27 April 2016

Debugging Mockito Stubs

I recently ran into an issue whereby the Unit Tests were failing after a raft of dev changes to some of our manager code. My IDE was giving me rather cryptic error messages.

It can be quite tricky to figure out what you have correctly stubbed when using mockito. Doing some digging in the debugger I was able to find the list of methods that have been stubbed out which vastly assists in debugging.

If you follow the tree
CGLIB$CALLBACK_0> handler>mockHandler>invocationContainerImpl>stubbed

You can see the valid stubs.

No comments:

Post a Comment