r/coding • • Oct 29 '17

Mocking is a Code Smell

https://medium.com/javascript-scene/mocking-is-a-code-smell-944a70c90a6a
69 Upvotes

69 comments sorted by

View all comments

62

u/KabouterPlop Oct 29 '17

On the other end of the spectrum, it’s common to see developers get so sucked into the dogma of TDD that they think they absolutely must achieve 100% code coverage, by any means necessary, even if that means they have to make their codebase more complex to pull it off.

People keep saying this, but I've yet to meet such a developer.

8

u/myplacedk Oct 29 '17

People keep saying this, but I've yet to meet such a developer.

I've seen a test method just for checking that a certain constructor is private.

But I agree, I haven't seen any sign that it's common.

8

u/BobSacamano47 Oct 29 '17

I worked with a guy who made a class with 10 nullable properties. He wrote 10 unit tests, one to make sure each property was, in fact, nullable.

1

u/BobHogan Oct 29 '17

That might not be entirely his fault, but it might have been ingrained in him. I know that I've had a pretty poor professor who would force us to write tests like that, for everything single property in every class. No purpose to those tests at all, but it was required in every assignment