Hacker News new | ask | show | jobs
by jerf 1248 days ago
"I've never never ever experienced in my life a time where a major problem was automatically found by some unit tests before it got pushed to production."

Then you, or somebody near you, is doing it very wrong. I do not mean this as a moral judgment, I mean it as an engineering process diagnostic feedback. I literally can't count the number of times it has popped up a bug that I wouldn't have expected because of some change.

It is that very characteristic that makes me love them so much. No matter how carefully you code you can never get away from the problem of a small change over there causing a breaking over here because of something you couldn't even have anticipated, but you don't have to wait until some large-scale QA process or even production deployment to find out; you can find out 15 seconds later, and then fix it, or realize your new change is fundamentally untenable, or any number of things. I'd say "I don't know how people develop without these things", except I do; the code bases are treated like quick-set concrete and nothing can be changed once laid down. What a stultifying way to code. I would hate to work at a job like that.

2 comments

> Then you, or somebody near you, is doing it very wrong. I do not mean this as a moral judgment, I mean it as an engineering process diagnostic feedback.

IMHO thats the biggest problem with TDD. People often think of TDD as a set of requirements that all push for some set of benefits.

But it is really a development methodology where you as a developer heavily utilize tests to drive the development process itself. It is a mindset, not a checklist.

Perhaps easiest to explain (with an inaccurate comparison) as - it is like REPL-driven development but with persistent and sharable artifacts.

Behavioral driven development is IMHO stronger in this regards, because people tend to understand how the additional artifacts (beyond what you might see with a requirements list or use case document) are part of a methodology. People can better separate the methodology from the benefits/outcome.

Here is the thing: Most managers want you to implement the test and the code in the same time It would take to write only the code.

The thing is, in the end most devs do shit tests becase theres no time allocated to that, and the test end up being just a number that needs to be met so the code could run to the dev ops engine and generte a new version of the software.

Tests typically let you write code faster because you can rely on the test suite to check most standard assumptions and inputs/outputs. Thus, you have significantly less to test as time goes on.
Not writing test code is faster the first day.

It's somewhat faster the second day.

It's a bit faster the third day.

It's probably net faster the fourth day, though by now you're developing noticeably more slowly.

It may still be net faster the fifth day.

It's net slower the sixth day, and the delta gets worse from that point on.

And I don't mean "per bug" on that, either. I mean, per project. By the sixth day of the project, you are net slower not writing any test code. And again let me emphasize net; by day six you are already losing overall.

Expecting test code to be written in the same amount of time as normal code is actually eminently reasonable, indeed it's the only sensible way to do it... if you do it right.