Live data from Hacker News

Why To Write Tests For Your Code

masternerd.lucianocheng.com

11–20 of 32 posts

Re: Why To Write Tests For Your Code

#11
post #4

I'd love to see an article on unit testing that gives reasons they add business value, so hackers like us can convince pointy headed bosses that we should be allowed the budget to write them. "Improving the quality of our software" is the one I tend to use, but it's so vague. How will unit testing convert into cold, hard cash is what upper management want to know.

It's hard enough to convince them faster computers add value. It's almost like they have never heard of the concept of Return On Investment. It's all about cutting costs and not about increasing profitability. We resorted to being very vocal about how much time they were paying us to sit and wait. Our non-tech wrangler got the picture.

Re: Why To Write Tests For Your Code

#12

Earlier quoted context omitted.

Can anyone tell me why they would not want to write tests? Laziness, ignorance, rapid prototyping, no budget, more important problems... all the obvious reasons. I can't think of any "good" reasons from an engineering perspective, only business.

Rapid prototyping is the best anti-testing reason I've heard yet. I even halfway agree with it. But in my experience, even prototypes can benefit from it. For me, testing actually makes the whole thing go faster. I spend less time worrying and more time developing, because I have the confidence that the rest of my code works exactly like I want it to.

Totally agree. We're following a lean startup approach and have identified our MVP and roadmap. Unit testing allows us to ensure our MVP works and that we have a reliable way to add features per our roadmap and still have a viable product. This sets the stage for us to rapidly and reliably enhance the UI, as well, while still shipping on time and getting customer feedback.

Re: Why To Write Tests For Your Code

#13
post #3

I am relatively new to HN and have _read about_ but not _seen_ an anti-testing mindset around here. I imagine this article will stir that debate if it exists. Can anyone tell me why they would not want to write tests? I have no biases here.

I assume that “not wanting to write tests” is when the tests are more complex than the code tested, for example writing tests for a GUI application using a closed-source platform framework is complex (if at all possible).

You can write tests for the core algorithms and data structures but that is often only around 10%.

Re: Why To Write Tests For Your Code

#14
post #3

I am relatively new to HN and have _read about_ but not _seen_ an anti-testing mindset around here. I imagine this article will stir that debate if it exists. Can anyone tell me why they would not want to write tests? I have no biases here.

Can anyone tell me why they would not want to write tests? Laziness, ignorance, rapid prototyping, no budget, more important problems... all the obvious reasons. I can't think of any "good" reasons from an engineering perspective, only business.

Rapid Prototyping gets my vote..I'm in the process of working on a prototype for a new web service that's attempting to make easier a very complicated industry (where things are evolving at a rapid pace). I've noticed that we never have any time to create test user cases, however I am working with 2 others who hire outsiders to perform real user tests, which works well enough for the time being...but testing only a few users, with a minimal amount of requests doesn't really give you a good indication of whether or not your application can handle the load of multiple users. From a functionality standpoint user testing is good, but from a stress-testing go-live standpoint it's not really that good an indication as to where you stand

Re: Why To Write Tests For Your Code

#15
post #4

I'd love to see an article on unit testing that gives reasons they add business value, so hackers like us can convince pointy headed bosses that we should be allowed the budget to write them. "Improving the quality of our software" is the one I tend to use, but it's so vague. How will unit testing convert into cold, hard cash is what upper management want to know.

I've seen a lot of this.. I don't believe in it.

You don't give reasons for using an ORM in your code, do you? You just do it as part of your development work. It's nothing that's being questioned by PHB's.

Writing tests is (or should be) part of your development work.

Make sure you include the time it takes to write the tests in your "time estimate".

Re: Why To Write Tests For Your Code

#16
post #3

I am relatively new to HN and have _read about_ but not _seen_ an anti-testing mindset around here. I imagine this article will stir that debate if it exists. Can anyone tell me why they would not want to write tests? I have no biases here.

If the project is new and the code is changing frequently tests slow me down and get thrown away frequently. So I don't write them until the app is on a stable path.

Re: Why To Write Tests For Your Code

#17
post #4

I'd love to see an article on unit testing that gives reasons they add business value, so hackers like us can convince pointy headed bosses that we should be allowed the budget to write them. "Improving the quality of our software" is the one I tend to use, but it's so vague. How will unit testing convert into cold, hard cash is what upper management want to know.

If you have a dedicated QA group, you can say it will decrease the amount of time QA spends on regression testing.

Re: Why To Write Tests For Your Code

#18
post #2

There are obviously many reasons, but to add a couple; Fight regression You don't want to fix the same bug several times, do you? When a bug is found, I first write a test to repeat the bug. Then I fix the code. Now every time I want to release a new version, that particular bug is tested yet again. The 'quick fix' 5 minutes before launch You're approaching deadline, everything is looking fine. Then, just before laun…

And, when it does happen, you thanks yourself for the times you thought it was unnecessary tests, but still wrote them to be safe.

Re: Why To Write Tests For Your Code

#19
post #3

I am relatively new to HN and have _read about_ but not _seen_ an anti-testing mindset around here. I imagine this article will stir that debate if it exists. Can anyone tell me why they would not want to write tests? I have no biases here.

If you're paid per hour and your client want you to take the less possible time. It's stupid; I agree. You can try argue with him/her about the importance of it, but in the end, it's their money so it's their choice.

Re: Why To Write Tests For Your Code

#20
post #9
post #3

I am relatively new to HN and have _read about_ but not _seen_ an anti-testing mindset around here. I imagine this article will stir that debate if it exists. Can anyone tell me why they would not want to write tests? I have no biases here.

I do not have a solid stance, but I am inconsistent on writing tests. I like to differentiate between the notions of hand-testing code and automated-testing code. I firmly believe code written should be verified somehow. I have not totally bought into writing tests. Right now, there is a lot of snake oil about what is better than what, and I would like to see good scientific studies that point in solid directions. So…

I am not so big on unit tests because I feel I mostly write glue code in rails were the problems are really not very hard.

What I really like is Selenium test that work like manual testing and I thus feel they just automate something I would need to do in any case.

Post reply on HN