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.

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

2 Answers 2

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.

4
  • 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
    Commented May 3, 2013 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
    Commented May 3, 2013 at 8: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.
    Commented May 3, 2013 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
    Commented May 3, 2013 at 14:55
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.

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