Live data from Hacker News

Ask HN: Do you write tests before the implementation?

news.ycombinator.com

161–170 of 329 posts

Re: Ask HN: Do you write tests before the implementation?

#161

Yeah. I also floss every day, clean up the kitchen as I cook, keep off-site backups of my personal data, call my mother regularly to thank her for raising me, read the terms and conditions to online services, keep an up-to-date to-do list, and change all my passwords once a month.

> read the terms and conditions to online services

sure you do

Re: Ask HN: Do you write tests before the implementation?

#163

Yeah. I also floss every day, clean up the kitchen as I cook, keep off-site backups of my personal data, call my mother regularly to thank her for raising me, read the terms and conditions to online services, keep an up-to-date to-do list, and change all my passwords once a month.

Yeah and some people are mediocre at their craft.

And some people are arrogant jerks, but I'd never jump to that conclusion after reading a single comment.

Re: Ask HN: Do you write tests before the implementation?

#164
I prefer BDD with parameterized test templates over TDD.

I give priority to end to end working of the software stack.

I always makes sure there that test suite should be executed in parallel threads.

I make sure that tests are written before I merge my code in the master branch.

Re: Ask HN: Do you write tests before the implementation?

#165
I usually start with a REPL, then play around with that for a while. For languages without a REPL I usually just create a one time file in the project and play around with that.

Once I am a bit more comfortable with the code and have a better understanding of what I need, I will start writing some tests. I usually don't write too many early on, this way I don't have to go back halfway through development and change all my tests. Only when I'm confident enough with the code do I start writing extensive tests and try to cover all cases.

Re: Ask HN: Do you write tests before the implementation?

#166

Earlier quoted context omitted.

To each their own. I have seen many times all the unit tests pass, but the application is broken. It really depends on the situation. There is no silver bullet when it comes to testing.

Yeah that's why "every" open source project you trust has a shitload of unit test. For amateurs, no tests, pros write test always.

In my experience, people who run around proclaiming how great they are and calling other people 'amateurs' are the real amateurs. The pros have seen enough to know that there are all sorts of ways to succeed and that (engineering) religion often gets you in trouble.

Re: Ask HN: Do you write tests before the implementation?

#167
post #117

Earlier quoted context omitted.

I see you're aiming for the sainthood too. You don't also happen to help elderly women across the road, let everyone else out at a junction and never fail to say 'please' and 'thank-you'?

At the risk of being serious for a moment, saying "please" and "thank you" are two of the lowest effort, highest reward, and plainly decent things you can do as a human.

Muh. It's OK to be one of those endless-pleasers-and-thankers, that's how you are... but stop being so fucking condescending about it!

...some of us "other kind" of people actually consider excessive politeness as offensive because it wastes time and pollutes conversations and after a certain we'll start actually being offensive with people like you, and you'll just stare amazed at how horrible people we can be! When in fact we're just snapping unable to put with more verbal abuse coming in terms of "please" and and "t you" from people like you.

Re: Ask HN: Do you write tests before the implementation?

#168
Depends. If it's a bug or a new feature built on top of code that is already tested, then I will write the tests because they fit nicely into already existing testing infrastructure. The test therefore "proves" the bug, and the fix eliminates it.

For outright new code (think new objects, new API, and so on), I tend not to write the tests first because they become a cognitive load that affects my early design choices. In other words, I am now writing code to make the tests pass, and have to exert effort not to do that.

Re: Ask HN: Do you write tests before the implementation?

#169

Yeah. I also floss every day, clean up the kitchen as I cook, keep off-site backups of my personal data, call my mother regularly to thank her for raising me, read the terms and conditions to online services, keep an up-to-date to-do list, and change all my passwords once a month.

> read the terms and conditions to online services sure you do

whoosh

Re: Ask HN: Do you write tests before the implementation?

#170
post #28

Yes. I like BDD, it helps me focus on the goal. I feel that it lets me find the right approach faster. Also, helps avoid distractions and optimizing things too early. Related: „Write tests. Not too many. Mostly integration.”, httsps://kentcdodds.com/blog/write-tests/

Typo in url: https://kentcdodds.com/blog/write-tests/
Post reply on HN