7

I understand the benefits of test driven development, but have there been any studies that reveal the level of satisfaction with the product or stress levels of the authoring developers with the introduction of unit testing?

I'm looking for case studies, or preferably research papers.

monksy
  • 649
  • 5
  • 18
  • A quick search on the [ACM Digital Library](http://dl.acm.org/) reveals *tons* of research papers for "test-driven development". – chrisaycock May 19 '12 at 23:09
  • 3
    There are a lot of papers on TDD but from the ones I found tend to match the marketing speak for TDD [its good for 'high stress environments'] – monksy May 19 '12 at 23:58
  • 4
    [answer to a possible duplicate question](http://programmers.stackexchange.com/a/148431/31260 "Has test driven development (TDD) actually benefited a real world project?") refers to paper that _demonstrates that TDD adds 15-35% development time in return for a 40-90% reduction in defect density on otherwise like-for-like projects..._ To me, _reduction in defects density_ sounds as close to _stress reduction_ as it gets – gnat May 24 '12 at 22:25
  • @gnat not by itself. You also have to consider how much time there is to fix those bugs. –  May 24 '12 at 22:34
  • @ThorbjørnRavnAndersen to me _density_ matters since less frequent bugs "convert" into less harm to _[flow](http://en.wikipedia.org/wiki/Flow_%28psychology%29 "what's this?")_, which in turn, "converts" to less stress. IOW even if it'd take same time total, larger chunks are beneficial stress-wise – gnat May 24 '12 at 22:38
  • @gnat given you have the same time in the two situations. You may not. –  May 24 '12 at 22:58
  • 1
    @gnat This is a more specific question to the link you provided. I don't care about project quality, has it improved the working life of the people writing the software. – monksy May 25 '12 at 01:16
  • @monksy caring about product quality is the most efficient way to stress relief for developer (one who ever dealt with angry testers / management / customers, likely knows what I mean) – gnat May 25 '12 at 06:35
  • 1
    I just want to say that I have reviewed many of the studies, and I find them lacking in scientific rigour. Observational studies are close to useless. What do we really know about benefits / drawbacks of TDD, not much other than personal opinions. Even if we suppose some of the figures are correct, if I spent another 35% of development time doing code reviews, design by contract, other types of testing etc, what would my reduction in defect density be? – Antonio2011a May 25 '12 at 10:15
  • 1
    @gnat: That doesn't answer my question. Caring about product quality doesn't equate to less or more stress. – monksy May 25 '12 at 14:19
  • @monksy if you focus exclusively on stress, that makes me wonder what does your question to do with ["conceptual questions about software development"](http://programmers.stackexchange.com/faq#questions "FAQ - What kind of questions can I ask here?")? In such a tight context, TDD becomes nothing more than yet another ergonomics trick, like "painting walls green or orange", "comfortable chairs" etc doesn't it? – gnat May 25 '12 at 14:43
  • No it remains the question that I originally asked. Does TDD have anything to do with adding more/less stress to the overall process. – monksy May 25 '12 at 14:59

2 Answers2

7

I don't personally know of any papers that focus on TDD vs Programmer Stress. I can really only offer you anecdotal evidence based on my own experience.

One of the more difficult things when I first tried TDD was to refocus my thinking so that it made more sense to write the test before the code. Often it simply felt easier to get my ideas into code, then follow up with tests. Over time I noticed that the number of noticeable bugs in my code didn't really seem to change and testing seemed to make me to appear to be working more slowly. In a sense, this contributed to additional stress at the time, as it felt like a failure in terms my ability to deliver quality work on time, and all of my scheduling estimates seemed to be way off of what I would have expected.

Fast forward several years with greater experience and the determination to see if I could actually make this approach work. I have changed my approach to using BDD as it seems to fit my mind set better, and to me feels like a better way to do TDD. Not only have I found that I work better this way, but that I can more easily keep myself focused on meeting only the specified requirements. I'm not wasting time with gold-plating, and I'm able to churn out code faster than I used to, simply because my efforts are more focused which ensures I am able to use my time more efficiently. This has had the effect of making even the more mundane tasks enjoyable when my test runner shows me all of my tests passing. I see my code quality improving also, and the code has become easier to maintain over time. All of this has made it much less stressful doing my work.

The thing is, that while I do see that things are better working this way, I can't really draw a direct correlation between TDD and less stress, because there are many other factors that have impacted on the quality of my work life. I have learned other skills over time that have also contributed to an overall reduction of stress levels. Some of those skills are interpersonal, some are simple mindfulness exercises, while other skills have been acquired as a result of reading lots of books about code quality and design which have all had their influence on the way that I go about my work. All of these elements contribute to the amount of stress that I perceive, but no one thing stands out as having had a significant impact by itself.

So while I can't really say that TDD itself reduces stress, I can offer the observation that TDD has helped to improve the way I write software. By helping to make my working life easier, I could argue that TDD has contributed in some way to helping me to maintain a less stressful working situation, but that it is difficult to directly measure the specific amount that TDD has contributed.

S.Robins
  • 11,385
  • 2
  • 36
  • 52
6
 > Test Driven Development, has it reduced stress for developers?

No but it has changed the kind of stress.

In non tdd legacy projects I have stress because of code quality and increased maintenance costs. Especially I have stress in judging why "this tiny change in program logic costs so much time and money".

In tdd projects there are "clever" stakeholders who want to further increase productivity by abolishing the "tdd-waste of time" with all its unnecessary code. So defending TDD is stress.

If you are more productive because of good code quality you have to implement more features in a given timeslot.

I can think of some non-tdd legacy projects that caused a lot of stress where I wished that they were tdd-projects.

gnat
  • 21,442
  • 29
  • 112
  • 288
k3b
  • 7,488
  • 1
  • 18
  • 31
  • 1
    k3b, you get it. This is exactly what I'm looking for. Has the developer's life become less stressful, and you hit the nail on the head. I would accept this answer, but I'm looking for a study to support the position. Here have an upvote! – monksy May 25 '12 at 14:15