0

We upgraded Junit framework from 3.x to 4.x. and In 4.x, each test method will be recognized by adding @Test annotation at top of the method.

There exists a test class with multiple test methods like test***() (around 250 methods). Do we need add @Test for each and every method? If not, what is the way to make sure all 250 run?

Kiran Nunna
  • 158
  • 3
  • 8
  • 20
  • 1
    Have a look [here](http://stackoverflow.com/questions/264680/best-way-to-automagically-migrate-tests-from-junit-3-to-junit-4). Pick solution / suggestion which best suits your need. – Bond - Java Bond Mar 10 '15 at 07:17

1 Answers1

0

When I had a large number of tests to convert, I used the JUnitConverter tool. It performs the following tasks:

  • Adding the @Test annotation before test methods.
  • Adding the @Before annotation before the setUp() method.
  • Adding the @After annotation after the tearDown() method.
  • Adding a static import for adding the different assert() methods.

It's not 100% perfect, IIRC, but it does a lot of the work automatically. I used it to convert Apache Commons Lang from JUnit 3 to JUnit 4 some years ago.

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254