power_settings_new

How to convert JUnit tests to TestNG

by
0 votes
199 views
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?

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.

1 Answer

by
selected by
0 votes
 
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:

 

image 
Convert from JUnit 3

image 
Convert from JUnit 4

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

image

The refactoring wizard contains several pages:

image

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.

image

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:

image

 
add
...