Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

They can require more setup in that you have to write an object to represent the thing.

They require less setup in that mocks require tons visual noise in setting them inside the test. Where as a fake will just be created with a standard constructor.

I hate a lot of mocking I see in real code. They go over board with the mocking and the test is 80% mock setup. Making it hard to see the real purpose of the test.

Tests should be short, simple, to the point, and easy to read. When most of the test is setting up a mock, you've lost that.

But there not too bad if it's a very simple one line setup. Which is how they should be used.

But that would not tell you that if you passed a null object into the real thing it would crash. Where as fake, with the tests will.



I think it really depends. If you keep the number of collaborators in a class small and your interfaces are well designed mocking is ok (and really just a limited form of a fake).

But sure, many people don't do that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: