3

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.

Ankit
  • 949
  • 4
  • 11
  • 15
  • 1
    Will the software be thrown away after 3 months? no feature extensions, no maintenance, no bugfixes? – Frank May 03 '13 at 05:15
  • Well Sir, 3 months include bug fixing and all. – Ankit May 03 '13 at 06: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 03 '13 at 07:56
  • @Ankit: you did not really answer Frank's question. – Doc Brown May 03 '13 at 09: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 03 '13 at 10:14

2 Answers2

5

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.

Eric King
  • 10,926
2

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.

MetaFight
  • 11,589
  • 3
    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 03 '13 at 07: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 03 '13 at 08:07
  • 2
    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 03 '13 at 12:33
  • 2
    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 03 '13 at 14:55