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.
"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.