Papers/Others

Mocks Aren't Stubs

tomato13 2007. 2. 17. 16:35

http://martinfowler.com/articles/mocksArentStubs.html

 

저자는 Test Double을 아래와 같이 정의하고 소개한다.

'Meszaros uses the term Test Double as the generic term for any kind of pretend object used in place of a real object for testing purposes.'

 

그리고 아래와 같이 4가지로 분류한다.

Dummy

Fake

Stubs

Mocks

 

Mock과 Stub간의 확연한 차이는 후자는 state verification만이 가능한데 비해서 전자는 behaviour verification이 가능하다는 것이라고 설명한다.


The key difference here is how we verify that the order did

the right thing in its interaction with the warehouse.

The second different thing in the second test case is that

I've relaxed the constraints on the expectation by using

withAnyArguments.

 


It has an advantage over the constraints of jMock in that you

are making actual method calls to the mock rather than

specifying method names in strings. This means you get to use

code-completion in your IDE and any refactoring of method

names will automatically update the tests. The downside is

that you can't have the looser constraints.