Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I work on projects which are usually of a duration, not more than 3 months. Recently there has been a discussion about the use of JUnit in the projects. There are activities being planned related to that and, there could possibly be some kind of training too. But I was wondering whether it is a good idea to use JUnit for such short term project? Isn't JUnit more suited for longer duration projects?

I need to know this, so that I can inform my team well in advance before any crucial hours are spent.

share|improve this question

marked as duplicate by gnat, Frank, Doc Brown, Bart van Ingen Schenau, Kilian Foth May 3 '13 at 8:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Will the software be thrown away after 3 months? no feature extensions, no maintenance, no bugfixes? – Frank May 3 '13 at 5:15
Well Sir, 3 months include bug fixing and all. – Ankit May 3 '13 at 6:40
There was a great comment from Jason Orendorff at the duplicate posting: "If your program is big enough to have bugs, it's big enough to have unit tests." – Doc Brown May 3 '13 at 7:56
@Ankit: you did not really answer Frank's question. – Doc Brown May 3 '13 at 9:57
I am sorry. Of course, the code will not be thrown away. So far there has been no extensions, but yeah there obviously be maintenance. Anyways I got my answer - Unit tests don't depend on Project duration :) – Ankit May 3 '13 at 10:14
up vote 2 down vote accepted

If you're positive your project will never be worked on ever again after those initial 3 months, then unit testing is less important.

If, on the other hand, it is quite possible that after some period of inactivity you require another development phase then unit testing is more important.

Your unit tests will really show their worth as automated regression tests. Long after everybody has forgotten the ins and outs of the code, your unit tests will be able to tell you when you've messed something up. They are an invaluable safety net in iterative projects.

share|improve this answer
I strongly disagree - I use a testing framework even for my small spare-time projects. It just pays off right after you write the first test. – Marcel May 3 '13 at 7:01
I'm not saying that unit tests aren't effective on small projects. I'm just saying they're less effective. This isn't because the tests themselves are any different, it's simply because they won't be used as often and won't ever take on the role of documentation. – MetaFight May 3 '13 at 8:07
the other point I think is that writing your code so that it is unit testable forces you to have a modular design – jk. May 3 '13 at 12:33
If I had a dollar for every time I saw a 3-month project that "will never be worked on again" still in production 5-years later, I'd be rich. – Eric King May 3 '13 at 14:55

Duration of the project is irrelevant.

If you have a project that might only take a few hours, and you want automated, repeatable tests, then use of something like JUnit is justified. Heck, I've been happy creating unit tests even for throw-away projects. The point isn't how long the project is going to take, but how useful having automated tests is going to be.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.