Why do we (not) write tests

To test or not to test
I read a great article on testing written by James Golick. There’s always a debate about doing unit testing or not. Most of the we-don’t-write-tests-because-we-don’t-have-time-to-do-it evangelists say that they have to implement features and release the product and that’s the reason they don’t write tests. I’ve felt this too, but that was before starting to write tests. It’s just like your old Honda, why buy a new one what the old one works so well.

I started writing tests when I begun working with Ruby and Rails. Before this, I worked in C, C++, Java, where you have to look for a testing framework, then learn how to use it, and then using it. Probably that’s why I’ve never done it. But when I started to learn Rails, and Ruby, and I saw the unit testing embedded into the language itself, it became so obvious and easy to try it. It’s hard to change the old habits. Even now when working on a new project I want to keep implementing features and never look back. But with mind discipline, I keep reminding myself that I need to write tests. Test-driven or not, during development it’s great to have tests. It’s assuring and comforting. And you’ll even sleep better at night. :)

We don’t need tests
Even though it’s been proved that writing tests is good, a lot of developers never write tests. And they always say that they don’t have time to do it, that they have to implement features, that they have to release on time, that they feel much comfortable with manual testing. Correct me if I’m wrong, but all the developers that started to write tests changed their mind about testing. And they keep writing tests for everything they do. To all the other developers: I don’t want to argue with you. I just have a suggestion: for your next project, do write tests and do it for a while. Never say Subaru or Honda is not a great car unless you’ve driven one. It’s the same thing. Never say testing is not good unless you’ve tried it. And not for a day or two. Do it for a couple of months. If you still feel it doesn’t help you than it’s fine. But unless you’ve tried it, don’t say it it’s not good.

Writing efficient tests
It takes some time to write efficient tests. The more you write tests, the better your tests are. Don’t expect to write efficient tests from the beginning. Just keep doing it, and you’ll see that your tests get better in time.

Testing is great for startups
When you have a small team, you can’t afford to spend time on testing…or better, on manual testing. Manual testing takes more and more time as you add features. So you have two options:

  • having a testing team, which means more money, and it’s a bad idea for startups;
  • developers test manually, which takes more time as you add features.

Having tests which run automatically saves you a lot of time, because you write a test, then a feature (or viceversa), and then another test, and another feature, one step at a time. At the end of the day you’ll have less features, but all of them are tested, and protected from now on by regressions. And this saves a lot of time you’d spend later on debugging and bug-fixing.

Another good thing when you have tests is that you can refactor your code more often and with more confidence. That’s because you have a suite of regression tests to back you up. And every time you refactor something, you can run the tests to see if you broke something. And the chances there’s a hidden bug which will appear on you live app decrease.

The danger of free…not so scary

I’ve read an interesting article at ReadWriteWeb about free content and giving away for free. I’ll start by saying I’m for the free content, and not against it.

It seems that more and more people are against free, and against giving away for free. This whole “for free” trend was probably started by Google. They had the search engine, they had the user-base, then they figured out they could display adds into the search results. And they were paid to do it. So they started displaying ads into mail listings also. Even though some argue that this is not good, I’d say it’s the key to the web evolution, and the key to our evolution: programmers, engineers, doctors, scientists, writers, and so on, can find a lot of useful information quickly and free. This was not possible 10 years ago, and it wouldn’t be useful today if the service was not free. Few people would use such a service if they had to pay for it. So you can’t argue that (at least) this free service helps our society evolve.

Why are we so afraid of receiving for free? Ok, we actually don’t get anything for free, we see the ads (more like ignore them, but that’s a different story) and for that we can use search, mail, access information all over the web. But guess what? We don’t care. I don’t mind that I see ads on the search results as long as I find what I want. And I don’t mind seeing adds next to my emails, as long as I have a 6GB storage in my Inbox.

Instead of being afraid of free, why don’t we adapt to free? Why don’t we work on changing the way we do business in order to stay competitive? Yeah, it’s easier to blame others when we feel losing ground, but instead we should adapt our business. This is one of the oldest rules of doing business, not just in the web, but everywhere.

I’m for free and because of these free services the advertising became what it is today. Because others give away for free we have to thing of better and more useful services just to stay competitive. And I wouldn’t mind getting free books either. :)