0

With Junit 4 I am seeing that there are two ways of getting fixtures setup/teardown:

  1. Decorate setup/tearDown methods with @Before and @After respectively
  2. Extend TestCase and override setUp/tearDown

I am trying to understand why two different approaches to doing the same thing. Is it related to option 1 being introduced after Java 5 annotations while TestCase is legacy from pre Java 5? Or perhaps I am confusing the two.

Any help will be appreciated.

sshekhar1980
  • 327
  • 2
  • 12

1 Answers1

1

The two approaches , as stated in this answer is because of what is introduced in Junit3 and Junit4. It also talks about why taking annotation way is better and its advantages.

If some of your testcase are wriiten in Junit3 way and now you want to use Junit4 but wondering how this can be done , then please have a look at this. It is explained there how tests, that are written old way, can be run with Junit4

user1207289
  • 3,060
  • 6
  • 30
  • 66