views:

94

answers:

3

Soon I will be involved in a project that will be using the agile project management/development approach, with 5 (or so) 2 week sprints. The project will be using a DDD design pattern which I have found in the past works great with unit testing, hence I have enthusiasim to use it for this project as well. The only problem is given the following factors I am unsure as to whether unit testing can be successfully implemented with agile development:

  • Potential for constantly changing requirements (requirements change, tests break, tests need to be updated too).
  • Time factor (unit tests can make dev take a fair bit longer and if requirements change towards the end of a sprint there may be too little time to update tests and production code at the best quality).

I have a feeling that if/when requirements change (especially if towards the end of a sprint) and given the tight deadlines unit tests will become a burden. Anyone have any good advice on the matter?

+6  A: 

I think it cuts both ways. On one hand, yes, unit tests are extra code which requires extra maintenance, and will slow you down a bit. On the other hand, if requirements start evolving, having unit tests in place will be a life saver in making sure what you are changing still works.

Mathias
Your second point is the most important in my books. Being able to change things safe in the knowledge that the rest of the system still works makes it much easier to make those changes.
Jamie Penney
Thanks for your answer, this kind of goes down the track of thought I had. Ah well, think we will be going down the TDD path, cheers!
Scozzard
Recently in SO in response to a question someone said that TDD is still pretty controversial. Is it true? If it is, then what are the reasons behind this controversy?
Night Shade
I don't think TDD is very controversial. Most people agree that unit testing takes time but helps development (and that usually the benefit outweigh the costs), but not everyone is convinced that writing the tests first is helpful. Writing tests first has value as a design process, but it doesn't work for everyone.
Mathias
+3  A: 

Considering 10+ weeks worth of code with no test coverage makes me cringe. When will you have time to manually test all that code? And under evolving requirements, you will use a lot more time tracking down impacts the changes will have throughout your code base.

I cannot advice strongly enough to use unit testing. Even when doing DDD, let unit tests drive implementation. Coupled with good patterns like DI/IoC and SRP, you should find both your code base and tests to be more resilient to change, and thus save you a lot of time throughout those springs.

Peter Lillevold
To answer you question the 'code' wouldn't be tested with unit testing, code would be peer reviewed and there would be user testing post deployment to a staging environment (no unit testing... O_o). DI/IoC is a goer for this which as you said will be helpful :). Thanks for you answer
Scozzard
A: 

Unless you have unit tests with high coverage, the cost of change will grow exponentially as the projects moves forward. So basically, the more change you anticipate the MORE you will actually need your unit tests.

Secondly, good unit tests depend on very few and small feature pieces in your production code. When this is true, only a few tests will be impacted when a feature changes. Basically, each test tests just one thing and small piece of production code. The key to writing unit tests that follow this principle is to decouple your code and test in isolation.

Thirdly, you need to get a better understanding of the concept of DONE and why its definition is so important in terms of sustainable development. Basically, you can't go fast over time in a sustainable fashion if your team compromizes the concept of DONE in the short term.

Mahol25