Selenium/TestNG/JUnit Migration to Katalon Studio
From Katalon Studio version 7.4.0 onwards, you can migrate your test cases from Selenium, TestNG, or JUnit projects to Katalon Studio. With the supported features and keywords, you can execute and maintain your existing Selenium, TestNG and JUnit projects with Katalon Platform without starting everything from scratch.
- Selenium version 3.x
- TestNG version 6.11
- JUnit version 4.12
You can download our GitHub sample project for TestNG migration: TestNG Migration.
Requirements
Katalon Studio version 7.4.0 onwards.
Supported features & keywords to facilitate the migration
Java class files
You can create, view and edit Java class files.
To create a new Java class file, in the Tests Explorer panel, go to the Include > scripts > groovy folder, right-click and choose New > Java Class. Choose a package and enter class name in the New dialog.
Built-in TestNG/JUnit keywords
Install TestNG/JUnit Keywords plugin
You can enable the built-in keywords in the manual view by using the TestNG/JUnit Keywords plugin. You can download the plugin from Katalon Store here: TestNG/JUnit Keywords.
After installing the plugin, go to Katalon Studio and click Reload Plugins.
If you want to use this plugin offline, you can refer to this document:Use Private Plugins. Because the TestNG/JUnit Keywords plugin is a platform plugin, you need to move the plugin package .jar file in the <project_name>/Plugins/platform
folder.
TestNG/JUnit Keywords
TestNG/JUnit Keywords Plugin offers 3 built-in keywords to help you run TestNG/JUnit tests as follows:
-
runTestNGTestClasses
Syntax:
runTestNGTestClasses(List testClasses)
Description: run TestNG test classes and generate TestNG report at the running report folder.
Parameters:
Parameters Type Description Mandatory testClasses List List of TestNG test classes Required flowControl FailureHandling Specify failure handling schema to determine whether the execution should be allowed to continue or stop. To learn more about failure handling settings, you can refer to this document: Failure handling. Optional runTestNGTestSuites
Syntax:
runTestNGTestSuites(List testSuite)
Description: run TestNG test suites and generate TestNG report at the running report folder.
Parameters:
Parameters Type Description Mandatory testSuites List List of TestNG test suites as .xml files Required flowControl FailureHandling Specify failure handling schema to determine whether the execution should be allowed to continue or stop. To learn more about failure handling settings, you can refer to this document: Failure handling. Optional runJUnitTestClasses
Syntax:
runJUnitTestClasses(List TestClasses)
Description: run JUnit test cases and generate JUnit report at the running report folder.
Parameters:
Parameters Type Description Mandatory testClasses List List of JUnit test classes Required flowControl FailureHandling Specify failure handling schema to determine whether the execution should be allowed to continue or stop. To learn more about failure handling settings, you can refer to this document: Failure handling. Optional
Migrate Selenium/TestNG/JUnit projects to Katalon Studio
Install Gradle version 5 or prior. You can download from the Gradle website here: Gradle.
To migrate Selenium/TestNG/JUnit scripts to a Katalon Studio project, do as follows:
-
Open a project in Katalon Studio.
-
Build project dependencies.
2.1 Open the .gradle file and add the Java dependencies of your Selenium/TestNG/JUnit project.
Note:- You only need to add the JUnit/TestNG project dependencies that are not Selenium dependencies.
- Katalon Studio has bundled TestNG, JUnit and Selenium dependencies, you don't need to declare those dependencies again.
2.2 Open the Command Prompt or Terminal and navigate to the folder of your project. Enter
gradle katalonCopyDependencies
, then wait for the Gradle to build successfully.
2.3 Reopen the project to reload all the dependencies.
-
Copy and paste the source code of your Selenium/TestNG/JUnit project in the
Include/scripts/groovy
folder of your Katalon project.
-
Copy and paste other resources of your Selenium/TestNG/JUnit project in the
Include
folder of your Katalon project (if any).
-
To reload the source code and resources from your Selenium/TestNG/JUnit project, right-click the
Include
folder, then click Refresh.
-
Create a test case that includes TestNG keywords to run TestNG test suites or JUnit test classes. To learn more about TestNG keywords, see above: Built-in TestNG/JUnit keywords.
For real-time monitoring and better reporting capabilities, consider integrating your project with Katalon TestOps. See also Upload Test Results to Katalon TestOps from Katalon Studio.
See also
- Import Selenium IDE version 3 projects
- Learn more with our Katalon Academy course: Migrate from Selenium to Katalon Studio – Everything You Should Know