← Back to Upcase

When to use Stub and when to Mock


(Damien Hogan) #1

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


(Damien Hogan) #2

Anyone :frowning:


(Derek Prior) #3

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?


(Damien Hogan) #4

Hey no I shall take a look. Much appreciated.


(Damien Hogan) #5

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