Hi Peter,
Thanks for your recommendation, it is a nice article to read!
As the author says, it is hard to say which one is better. I think every technique has its advantages and disadvantages, and no method can solve all problems. The best way is to try it with some tests and find out which one is more suitable for our case or for some classes.
I will do the test by using the state-based test and the stubs and waiting for your new experience of Interaction-based test:)
Best regards,
Bob
Peter Dimov wrote:
Dear all,
As most of you already know, I’ve been studying and experimenting with unit testing concepts recently. I wasn’t clear about the differences between stubs and mocks and after some searching I came across this interesting article from Martin Fowler:
http://www.martinfowler.com/articles/mocksArentStubs.html
It would make a good read for anybody interested in the topic. The article show examples that use mock frameworks for Java so I did a search for C++ mock framework and found MockPP:
http://mockpp.sourceforge.net/
I haven’t tried it out but plan to do so soon. I’m now working on a remake of Connection and PacketSession with good unit test of course. I’ll publish a patch as soon as I have some good progress to show.
Best regards,
Peter
