gnecula / bond

Spy-based testing library.
http://necula01.github.io/bond/
Other
7 stars 3 forks source link

Using spies to construct mocks #17

Open gnecula opened 9 years ago

gnecula commented 9 years ago

This is more of an idea for extending Bond.

I am in the middle of writing tests for a complex REST api interaction with multiple dependent round trips. It is a pain to collect the mock results. I keep going back and forth between the production system and the test, trying to get to the response to my requests in a debugger to save them to a file so that I can use them in mocks.

It just occurred to me that we are in a unique position to use spies to actually build the mocks. If you somehow turn on spying in production code, then you can use those observations as mock results.

Other mocking systems that are not coupled with spying may not be able to use replay. I am wondering how exactly to do this.