atom feed6 messages in org.codehaus.jmock.userRe: [jmock-user] jMock vs EasyMock
FromSent OnAttachments
Emerson FarrugiaNov 20, 2007 7:15 am 
Steve FreemanNov 20, 2007 2:49 pm 
Tom AdamsNov 20, 2007 2:53 pm 
Nat PryceNov 20, 2007 3:04 pm 
Tom AdamsNov 20, 2007 3:17 pm 
Tom AdamsNov 20, 2007 3:57 pm 
Subject:Re: [jmock-user] jMock vs EasyMock
From:Tom Adams (tomj@gmail.com)
Date:Nov 20, 2007 3:57:56 pm
List:org.codehaus.jmock.user

Emerson,

Some thing else that may be relevant to your discussion. I find that mocks are used in two ways, firstly in interaction tests and secondly to drive design.

Using them purely for interaction tests can lead to problems if you go too far. You're tests become coupled to the code and hard to refactor. You also end up not really "testing" anything, and rely on other tests (integration, etc.) to catch runtime errors (you need these tests anyway, so this is not that bad). You also start to find that your tests look exactly like your code, and they start to not help you drive design. This is especially a problem when you work from the bottom up (build the collaborator first, then mock it's use), rather than top-down (drive the design of the collaborator first, then create the collaborator).

I've found that I don't get the full benefit of mocking if I use it this way, so I've now started trying to avoid overusing mocks, and now only use them in two places. 1) For driving the design of collaborators and 2) for specifying true interactions, where the subject under test is transforming or coordinating the interactions of its collaborators.