When you’re facing the issue to migrate your JUnit 3 tests to JUnit 4, it can be very annoying, because of course you all have a lot of tests. ;)
In general it is a mindless task to migrate things that have been changed due to a new major release.
For JUnit 4 one of the most popular features, which are new compared to JUnit 3, is the usage of Annotations and Pojos for test classes.
So what has to be done in order to migrate a TestCase:
- Remove the inheritance from TestCase
- Add static imports for org.junit.Assert methods, as these are not available from inheritance any more
- Make setUp() method public and add @Before annotation
- Make tearDown() method public and add @After annotation
- Add the @Test annotation to your test methods
Quite a lot of work, if you have to do it manually, isn’t it?
After you have installed this plugin you can trigger the follwing action on every Java project, java package or java class in the package explorer by selecting Soure > Convert to Junit 4.
As one of our aims at the vogella company is keeping the Eclipse code clean and modern the migration of the Eclipse tests to JUnit 4 is currently in progress.
 https://github.com/SimonScholz/codemodify - Github repo with Sources
 http://dl.bintray.com/vogellacompany/junit-4-tools/ - P2 updatesite to directly install it