• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

pros & cons of JUnit

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the pros & cons of JUnit ? (Why should i go for junit test classes instead of writing my own test classes for java )
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) JUnit is the de facto standard library for unit testing in Java
2) JUnit is supported out of the box by all major IDEs
3) JUnit has sh*tloads of extensions available for various purposes beyond unit testing plain old Java objects (HttpUnit, JWebUnit, XMLUnit, dbUnit, TagUnit, J2MEUnit, JFCUnit, JUnitPerf, Cactus, SQLUnit to name a few)
4) JUnit has great Ant integration via the <junit> and <junitreport> tasks
Some folks have minor complaints about the restrictions JUnit enforces on your test code, but these issues tend to be really minor annoyances. In fact, most of the time the complaints come up because people try to use plain JUnit for things other than unit testing.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more thing...

Originally posted by ashok ks:
Why should i go for junit test classes instead of writing my own test classes for java?

This could be answered with a question: why should I use Eclipse instead of writing my own IDE?
Most of the time, it makes sense to use an existing product instead of building your own. The main reasons for building your own are (1) significant overhead in learning the product, and (2) limitations of existing products. I doubt that the learning curve of JUnit is even close to that of building your own unit test framework, but eventually it's you who needs to make that call.
 
author
Posts: 799
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
most of the time the complaints come up because people try to use plain JUnit for things other than unit testing.


Or when you try and work with the JUnit source code. ;-)
JUnit is free, it's simple to work with, it's the standard, as Mr Koskela said. There's little reason not to use it.
-Jeff-
 
ashok ks
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
Whether JUnit reduces the testing part coding compared with the own java test programs ?
 
Jeff Langr
author
Posts: 799
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It will reduce your code a bit, but the more important thing is getting a consistent framework in place.
-Jeff-
 
reply
    Bookmark Topic Watch Topic
  • New Topic