Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

How to convert JUnit tests to TestNG

Solved 1 Answers 154 Views Selenium
0 1
We are widely using JUnit for our selenium tests. Now we have plans to migrate to TestNG. Is there any effective way of doing the same?

1 Answer

Best answer

Using Eclipse:

You can easily convert JUnit 3 and JUnit 4 tests to TestNG.

Your first option is to use the Quick Fix function:


Convert from JUnit 3

Convert from JUnit 4

You can also convert packages or entire source folders with the conversion refactoring:


The refactoring wizard contains several pages:


This page lets you generate a testng.xml automatically. You can configure whether to include your test classes individually or by package, the suite and test name and also whether these tests should run in parallel.


This page gives you an overview of the changes that are about to be performed. You can also decide to exclude certain files from the refactoring.

When you are done, press the "Finish" button. Like all Eclipse refactorings, you can undo all these changes in one click:


answered by
selected by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.