Everybody Tests
Everybody has to test their code. It's just that those of us who write automated tests write code to do our testing, where non-testers use humans (themselves, usually) to manually verify correct behavior. So, we can be sure that the testing-slows-us-down argument rests on the premise that manually verifying behavior is faster than writing automated tests.Investing Time
The two methods of testing distribute your time investment differently. Since automated tests run very quickly, the time investment is made in writing them. Running the tests is nearly instantaneous. With manual testing, it is the opposite. Designing the tests takes nearly zero time, whereas actually running the tests takes a measurable amount of time each time you need the test. So, with automated testing, you get most of your time investment out of the way at the outset. Once it's written, it's written. With manual tests, your time investment grows each time you test for something. In order for the testing-slows-us-down argument to remain valid, the total time investment made on manual testing must be less than the time investment required to write the automated tests.In these terms, the testing-slows-us-down argument can be expressed as follows: The time it takes to write the automated tests for a feature is greater than the total time that will be spent manually testing that feature throughout the lifetime of the project.
Since one of my goals for this article is proving the "no time to test, we need to launch our product" people wrong, I want to show that this (short-sighted) argument is as, if not more, flawed than the testing-slows-us-down argument. I'm going to phrase the product-launch argument as follows: The time it takes to write the tests for a feature is greater than the total time that will be spent manually testing that feature until product launch.
Breaking Even
If it takes twenty minutes to write your automated tests, and one minute to test your feature manually, the break even point for an automated tester is when they've run their tests twenty times. After that point, automated tests become cheaper and cheaper (per test). Manual tests continue to become increasingly expensive over their lifetime. So, the testing-slows-us-down argument can be rephrased once more, making use of our new terminology: The automated testing break even point will not be reached before product launch.
Developers Developers Developers
Because the cost of manual testing grows considerably each time you run your tests, bringing on extra developers adds a multiplier to your (growing) test cost. Anytime any developer wants to merge their branch back in to trunk, they're going to have to take a look over the whole source tree to make sure they didn't break anything. This means, for the reasonably attentive developer, testing code that they didn't write - going over all of the features. It's the manual testing equivalent of running the whole test suite. Not only is this a time-consuming process, but it is incredibly error prone.Debugging Time!
No developer can be reasonably expected to remember, and meticulously verify all of expected functionality from an application, at each check-in. That's a superhuman expectation. You might even say it's a job better suited to a machine? Seriously, though, code is interdependent. Changes in one area can have impacts all over the application. When relying on humans to verify application behavior, a lot of bugs are going to slip through the cracks.More bugs means more time spent debugging, which, incidentally, means more time spent testing, for the manual tester. Moreover, it's not uncommon for the same bug to surface repeatedly. We've all seen it. It's called regression, and it's why us automated testers have something wonderful called regression tests.
With every bug, automated testers (like always), make a one time investment. Since automated testing is far more likely to prevent regressions than manual testing, the time benefits here are two-fold. First, once the regression test is written, it's written, and the behavior doesn't need to be repeatedly verified by hand. Second, the bug is far less likely to resurface. Manual testers may argue, here, that they are capable of adding the regression tests to their regular passes over their code, keeping the bugs out, just the same. While this may be the case for the most superhuman of individuals, the liklihood that an entire team may be capable of such incredible manual testing is very low.
So, as a general rule, I think it's safe to say that automated tests significantly reduce debugging time, by providing a much higher degree of accuracy, and acting as a powerful weapon for preventing regression.
Release Already
It seems pretty clear to me, after a thorough analysis of the testing-slows-us-down argument that its proponents are, at the least, misguided. Automated testing is at least as fast as manual testing. In writing this article, I thought a lot about why so many people have this common misconception. I think it mostly stems from one of the following.The most common cause of this misconception is likely naivete. Many of the challenges that really bring out the best in automated testing (and, consequently, the worst in manual testing) are far more evident with bigger projects. While I maintain that automated testing is at least as fast as manual testing on all projects, it's likely that bigger projects will see much bigger benefits. The problem, here, is that big projects often start out as small ones. And, unfortunately, growing pains can cause some of the most difficult problems with keeping software working properly.
My assumption is that the ones who aren't naive are just lazy. Learning how, what, and when to write automated tests can be a difficult undertaking, but it's well worth it. Like writing the tests themselves, a little bit of up-front investment in your skillset will save you loads of time, and headache later on. So, do yourself a favor, and learn to test. You'll thank yourself for it.
Update: See my first response in a new series to some of the discussion surrounding this article.


And for everybody who is looking to pick up the pace of their test adoption, I have some screencasts in the works for testing beginners. Is that something that interests you guys? Would you like to beta test them? Email me.
I think a big part of the reason that people think automated testing is expensive is because most of them lack the skill to design for testability. If you start with a big codebase that has never had any tests, it can be very, very difficult to write tests for it that achieve meaningful coverage. Usually it will require refactoring the code; so it’s a big and risky investment for what seems like an unclear benefit.
No wonder they think it’s a waste of time.
The problem lies in development time planning, though...
So, well, projects end up late... They end up late because debugging time has been under-evaluated at planning stage.
And when that big "we're late" meeting happens, who can afford to say "we're late because automated test routines took longer to write than expected ?" especially when there are big bugs in the base that the automated test routines didn't catch (Murphy's law always applies)...
So, before you throw yourself into big amounts of automated testing, make sure you have a large "time budget" for it, make sure everybody realises that "writing the code" takes a lot less time than "making it work" ;)
@Miklos Hollender: You need to write them because not all tests are simple enough to describe in a spreadsheet. That said, there's a look that does what you're talking about: Fitnesse.
Jonathan - If the requirements are to fuzzy for the developers to test them, then how can they write any code based upon them? Do they just put some code together to see if they by cheer luck managed to understand the requirements?
@Jonathan - If the requirements are to fuzzy for the developers to test them, then how can they write any code based upon them? Do they just put some code together to see if they by cheer luck managed to understand the requirements?
I agree with everything in this blog post - but unfortunately there's a few dirty little secrets in Software Development that keep preventing TDD from being adopted.
1) The manual tests aren't always run! Perhaps the developer doesn't feel its necessary (wrong) or the doesn't know that a certain test should be run (ignorance). This was "addressed" at one of my previous employers by - I kid you not - word documents with checklists. Your Number of time spent on tests vs. time spent on tests fails to account for this, and worse yet oftentimes managers do not want developers "wasting time" on basic tests, that's what testers are for (also wrong).
2) Delusions of Grandeur repeatedly overwhelm project schedules. Bugs? What bugs? Since your schedule doesn't include any debugging adding tests "adds time".
3) Many managers don't care at all about quality. They pay it lip service, but time is always their chief constraint. Furthermore since the people in charge of development often have never been developers they have no insight into how it works. For example developer A and developer B write similar modules. Developer B proclaims it done two weeks before developer A, and spends the next month fixing bugs reported in testing. Developer A wrote tests as he went and has 0 bugs (contrived example). Review time comes and Developer A is often asked, "Why aren't you as fast as Developer B?" Never mind that B was actually 2 weeks later, none of that time counts.
When told that developers don't test their code I ask "Then how do you know it works." At which point they'll say something along the lines of trying it out on their machine, so I just ask, "So why don't you automate that?" Sometimes that gets them thinking anyway.
@Eric - you're basically right. The situations you're describing don't disprove my argument, though. The fact still remains - you're spending the time, whether you like it/know it or not.