2 ms·
Why do fakes need tests, but mocks don't? In one case you create the class on your own, in the other case the mocking framework does that for you on the fly. W
by andix 6y ago
Why do fakes need tests, but mocks don't?
In one case you create the class on your own, in the other case the mocking framework does that for you on the fly. With both approaches you can do very basic or very complicated things.
Or do you have a rule in your company that every class needs a test? Maybe this rule is the problem.
- throw_m239339 6y ago> Why do fakes need tests, but mocks don't? because no new class or method is created with mocks, it's merely declarative, no new logic is created than needs to be tested. Fakes very much have logic since they are implementations of classes. > Or do you have a rule in your company that every class needs a test? Maybe this rule is the problem. No Fakes are, not the fact that every unit should be tested. Fakes are very much a unit, the fact that they are classes is irrelevant. furthermore: https://news.ycombinator.com/item?id=24774752 https://news.ycombinator.com/item?id=24774752 which demonstrates my point. I don't want to have to write tests for tests.
- srtjstjsj 6y agoTo put it differently, mocks aren't tested because they can't be wrong, be at they are "not even wrong". You have to have faith that mock behavior is actually a reasonable emulation of the real system, without ever checking. The weakness is that your tests of the system under test don't help you find flaws in how the system under test uses the lower level dependency, because you are simply forcing the lower level dependency to behave the way you wish it would.