When to use Stub and when to Mock

Hello,

I have been going through the TDD workshop and noticed that the on numerous occasions stubs and mocks were used, however I feel that I have not managed to truly and a decent understanding of when to actually use both approaches. I have had a search around the net and found some definitions, but I was wondering if someone could give me an example of when you would want to stub and also when it would be beneficial to use mock or double.

Any help would be very much appreciated.

Damien

Anyone :frowning:

The canonical article on this is from Martin Fowler. Mocks aren’t stubs. The examples are in Java, but their specifics aren’t super important.

Have you read that?

Hey no I shall take a look. Much appreciated.

I also found this which has a good view point regarding stubs and doubles.