Using TypeMock vs. Design for testability

Eli Lopian, the Israeli guy who is now running TypeMock - one of the most powerful Mocking frameworks out there for.NET developers, opened a blog. I personally know the guy and he is a brilliant coder and architect - so it's worth listening to what he has to say.

For example. in this post he lists resources for and against using TypeMock  because of the design issues you can run into - you don't have to design for testability if you use it - you just intercept all calls to objects(even static ones) when you test. it's really quite scary and too easy - does not make you think at all.

I'm from the "Design for testability" side. Eli is not - and he always has interesting arguments. He even wrote a rather controversial article on codeproject talking about this issue. Read it to get both sides.

Published Wednesday, September 27, 2006 1:17 PM by RoyOsherove

Comments

Thursday, September 28, 2006 3:12 PM by Colin Jack

# re: Using TypeMock vs. Design for testability

I haven't read his code project article in detail but I agree with the sentiment. I actually do like TDD, a lot, however I don't design my classes to allow easy mocking because I've found it ends up overcomplicating your design in ways that aren't useful. I actually think its not particularly clear cut either way. For example Robert Martin's excellent book on agile development correctly indicates that you should avoid needless complexity however he also believes that you should design for testing. But do I really want to use interfaces/IOC/dependency injection/factories/registries or whatever else just for testing when I can just use TypeMock instead? Is all that decoupling really going to be worth it in the future or should I just wait till I actually have a real need for the decoupling (at which point I can create really useful interfaces that do exactly what I need them to do). Anyway thats my 2c. Oh and I'm new to the whole blogging thing but I've posted on this a while back: http://colinjack.blogspot.com/2006/08/typemock-helps-improve-your-designs.html
Saturday, September 30, 2006 12:33 PM by Yoni

# re: Using TypeMock vs. Design for testability

I read the article and I couldn't disagree more. One of the things I like most about TDD is the ability to do a lot of refactoring with ease. In order to refactor I have to be sure that the changes I make do not affect the system's features (namely - my tests). TypeMock (or at least it's usage as described in the article) advocates tests which are coupled to implementation in a way that renders it impossible to refactor without changing the tests (which isn't really refactoring at all...).
Monday, October 02, 2006 11:04 AM by Colin Jack

# re: Using TypeMock vs. Design for testability

Does the Natural Mocks feature not deal with that though?
Saturday, November 17, 2007 4:50 PM by ISerializable - Roy Osherove's Blog

# Mocking LINQ Queries, Extension methods and Anonymous Types

One of the things I wanted to show at my Interactive session on unit testing tips and tricks at TechEd