New answers tagged

1

I can relate to your expierience - our code base had almost no tests and was mostly untestable. It took literally ages to develop something and fixing productions bugs took precious time from new features. For a partial rewrite, I vowed to write tests for all core functionality. At the beginning, it took considerably longer and my productivity suffered ...


2

Question is, how much of a time difference would writing unit-tested code over untested code, and how does that time difference scale as project scope widens? The problem gets worse as the age of the project increases: because whenever you add new functionality and/or whenever you refactor existing implementation, you ought to retest what's previously be ...


2

There have been a long history of Programmers board promoting TDD and other test methodologies, I won't recall their arguments and agree with them, but here is additional things to consider that should nuance a bit: Testing isn't equally convenient and efficient depending of context. I develop web software, tell me if you have a program to test the whole ...


14

Despite there being a lot of answers already, they are somewhat repetitive and I would like to take a different tack. Unit tests are valuable, if and only if, they increase business value. Testing for testing's sake (trivial or tautological tests), or to hit some arbitrary metric (like code coverage), is cargo-cult programming. Tests are costly, not only in ...


2

Programmers, like people dealing with most tasks, underestimate how long it actually takes to complete it. With that in mind, spending 10 minutes to write a test can be looked at as time one could have spent writing tons of code when in reality, you would have spent that time coming up with the same function name and parameters you did during the test. This ...


1

Some aspects to consider, not mentioned in the other answers. Extra Benefit/Extra Cost depend on experience with writing unittests with my first unit-test project the extra costs trippled because i had to learn a lot and i made a lot of mistakes. after 10 years of experience with tdd i need 25% more coding time to write the tests in advance. with more ...


1

An oft overlooked benefit of TDD is that the tests act as a safeguard to make sure you aren't introducing new bugs when you make a change. The TDD approach is undoubtedly more time consuming initially but the takeaway point is you'll write less code which means less things to go wrong. All those bells and whistles you often include as a matter of course ...


100

I agree with the rest of the answers but to answer the what is the time difference question directly. Roy Osherove in his book The Art of Unit Testing, Second Edition page 200 did a case study of implementing similarly sized projects with similar teams (skill wise) for two different clients where one team did testing while the other one did not. His ...


28

There is only one study I know of which studied this in a "real-world setting": Realizing quality improvement through test driven development: results and experiences of four industrial teams. It is expensive to do this in a sensible way, since it basically means you need to develop the same software twice (or ideally even more often) with similar teams, and ...


23

Done well, developing with unit tests can be faster even without considering the benefits of extras bugs being caught. The fact is, I'm not a good enough coder to simply have my code work as soon as it compiles. When I write/modify code, I have to run the code to make sure it does what I thought it does. At one project, this tended to end up looking like: ...


7

It depends on the person, as well as the complexity and shape of the code you're working with. For me, on most projects, writing unit tests means I get the work done about 25% faster. Yes, even including the time to write the tests. Because the fact of the matter is that software isn't done when you write the code. It is done when you ship it to the ...


130

The later you test, the more it costs to write tests. The longer a bug lives, the more expensive it is to fix. The law of diminishing returns ensures you can test yourself into oblivion trying to ensure there are no bugs. Buddha taught the wisdom of the middle path. Tests are good. There is such a thing as too much of a good thing. The key is being ...



Top 50 recent answers are included