• 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

jUnit conceptual question

 
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have recently starred using jUnit to write test cases. While, googling for tutorials, i came across two approaches to write test cases:

> Using Annotations (@Test)
> Extending TestCase class

However, i never could find the possible differences between them, and what i should be using in my code. I know, extending TestCase class is not a suitable option, since i cant extend anyother class if i do this. Can anyone provide me with more differences, preferably the scenarios where i should use particular implementation.

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Extending TestCase" is the old way to do it, but it's still being used. Annotations were introduced since JUnit 4. The advantage is that you can annotate any method to be setUp, tearDown and test methods. The biggest difference I think is that, to use annotations, you'll need at least Java5. If you're stuck with Java1.4 or less, the only way to mark your tests is by extending TestCase.
 
chander shivdasani
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. Now it makes sense to me
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One issue is that if you're forced to extend TestCast you can't extend anything else--that may or may not be an issue for any particular test.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic