Mar 29, 2011

Excuse #1 - Writing tests takes too much time

This is the most common excuse in the "Testing: Why Bother?" series, so I'm going to address it first.
It turned out to be a pretty long post (and only the second of several more), but I really think if you'll read everything through it will give you some new insights.

So... are you claiming testing doesn't take time?
Well... Of course I'm not. Testing is not free, and you don't HAVE to write automated tests in order to write code that eventually works. But is it really not cost-effective?

When I demonstrate unit-testing or TDD to developers new to the field, I frequently get reactions such as "well, that's nice, but I could have implemented the same code much faster without tests."

This statement might be true, but there are several reasons why I think by testing you actually save time:

  • You don't have to start thinking how to verify that your code works (you already did this)
  • You are already after the debugging phase
  • You ensure having automated tests that can run later on
There's also the concept of improving design and usability of your code by testing it, which may also save you time in future, but that's something I'm going to talk about more in the next posts of this series. 

So lets' dig in and elaborate on all of these points.

Mar 27, 2011

Testing: Why Bother? - Introduction

I stumbled upon an interesting discussion this week in the testing-in-python mailing list, asking how to explain why testing is important to a "we do not write tests" audience. Because this is something I had to do a few times already, I thought about writing a blog post about it (actually, a series of posts...)

Testing? What do you mean by that?
Well, there's a lot of things that can be related as "testing" when talking about software development. There's TDD, Unit tests, Integration tests, having a QA engineer test your code, and more.
In these posts, I'm talking about justifying writing any kind of automated tests that can be run through a CI (Continuous Integration) system after each commit. It doesn't matter if they were originally written during practicing TDD, the important thing is making sure there's something that's always there to test nothing was broken after each little changeset in the code.

So, what's the deal? Why do I need to write tests?
Well, the advantages of testing your software are usually clear and aren't really debatable.
Every one will agree that when you write and run automated tests for your code, you become more confident that your code works, and when you run your tests after each change you make you can gain confidence that you didn't break anything.
The problem is, though these advantages are pretty much obvious and clear to anyone, the majority of developers do NOT write automated tests.

But, if testing is so awesome, why wouldn't everyone write tests?
Well, there are 2 kinds of anti-testing developers (that's how I'm going to refer to them from now on).
One type of anti-testers, are the kind that simply lack the education. Most programmers don't learn how to write tests as part as their formal education, and therefore when they start at their first software industry job, they usually don't write tests unless exposed to this subject as part of the company's training and mentoring. Because concepts like TDD and CI are relatively new, a lot of old-fashioned team leaders and R&D managers are not exposed to the importance of testing as well, and they don't demand this from new employees and don't include this in training them to the job.
These kind of anti-testing developers are the relatively easy kind. They did not already develop antagonism towards testing, and they may be easily persuaded by fellow pro-testing developers, teammates, managers or external preachers.
The other type of anti-testing developers, is the type that I'm targeting these blog posts towards. These are developers that are already exposed to the concepts, maybe even experimented with testing a little bit in the past, but claim to have some solid reasons why testing is a waste of time for them, and simply do not believe in it. There's usually a list of excuses they give to justify their hostility towards testing.

The list of excuses
In my experience as a pro-testing preaching developer, I've come across some various types of resistance. I've collected a list of common excuses for justifying the anti-testing approach:

In my next posts, I'll try to attend all of these excuses, and clarify why I think they are plain misconceptions.

Can you think of any more excuses? Please let me know in the comments.

Mar 26, 2011

First Post

I'm Yoni Tsafir and I'm a software developer from Israel, currently working at IBM (XIV Storage Systems).
Throughout my years as a software developer, I commonly found myself in the position where I'm aspiring to find ways of making myself and my teammates work better and more effectively, applying agile practices such as unit-testing, pair-programming, TDD, continuous integration, and so on. 
Because of my passion to the subject, insisting of everyone writing an informative commit message, not changing code without making sure there's a test for it first, and so on, in one of my teams I even earned the nickname "The Bad Cop of Code", hence the idea for a name for my blog.

Following the lead of many great minds I appreciate, I decided to start my own blog and share my thoughts.

This blog is going to talk about all these subjects I mentioned, and more. It's going to contain tips I gathered from my experience and try to make it easier for fellow "bad cops of code" like me to explain to their fellow teammates why these concepts are important.

Something else that I have a lot of passion to is music. I'm a music composer, recently composed some TV shows, DVD and musicals for children in Israel. This is something I'll try to take advantage of in order to spice up my posts and share some off-topic interesting content related to the intersection between music and software.

Hope you'll enjoy reading.

Finally, I would like to acknowledge some of the other software related blogs, as they were the main inspiration source I had for starting my own.

  • Aviv Ben-Yosef's The Code Dump. Aviv is one of the most, if not the-most talented developers I've ever met, and I even had the pleasure of working and pairing with him for a few years. His blog has some amazing posts and ideas.
  • Iftach Bar's Nash Code Bar. Contains an amazing post about hudson/jenkins. Hope to see some more posts like this in the near future!
  • Uri Lavi's Blog. Founder of the Software Craftsmanship group in Israel (SCIL).
  • Uncle Bob's Blog. Author of Clean Code. Contains excellent videos and posts.
  • GeePawHill's Situated Geekery. Some of the bests posts I've read about TDD.
  • Lior Friedman's IMistaken. Lior gave a very impressive talk in SCIL, and since then I started reading his very good blog.
  • Ran Tavory's PrettyPrint. Ran is a fellow member of SCIL, besides a great podcast (reversim) he runs, he also has a great blog.