One Click Test Conversions
Join the DZone community and get the full member experience.Join For Free
if converting your tests to testng is one of your new year’s resolution, you are in luck. introducing the improved junit to testng converter.
a couple of months ago, i gave a preview of the new features in the testng eclipse plug-in and i observed that more and more people were converting their tests from junit 3 and junit 4 to testng. this latter was a surprise to me since i never really expected anyone would want to move away from junit 4 once they have migrated to it.
testng has long supported individual class conversions in the form of quick fixes:
i recently expanded this support and turned it into a full refactoring, which means that you can now apply it to entire packages, source folders or even projects.
to use it, install the latest testng eclipse plug-in , open your package explorer and right click on either a package, a source folder or a project:
the refactoring wizard contains two pages.
the first one lets you customize the testng.xml that’s about to be generated (you can also choose not to generate one):
the next page shows you a view with all the changes that are about to be made to your source files. these changes are similar to the ones made with the quick fix except that they now apply to multiple files:
on this page, you can exclude certain files from being converted, and when you’re happy, press the finish button.
like all refactorings in eclipse, you can undo your changes in one click if you change your mind:
in a next post, i’ll show how you can use this new functionality to help you check that your unit tests are as isolated as you think they are.
now go ahead and convert your tests, that’s one less new year’s resolution you have to worry about!
Opinions expressed by DZone contributors are their own.