Skip to main content

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.

Katalon Studio supports:
  • 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.

Create Java Class files

Sample Java Class file

Sample Java Class file

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:

    ParametersTypeDescriptionMandatory
    testClassesListList of TestNG test classesRequired
    flowControlFailureHandlingSpecify 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:

    ParametersTypeDescriptionMandatory
    testSuitesListList of TestNG test suites as .xml filesRequired
    flowControlFailureHandlingSpecify 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:

    ParametersTypeDescriptionMandatory
    testClassesListList of JUnit test classesRequired
    flowControlFailureHandlingSpecify 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

Important:
  • 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:

  1. Open a project in Katalon Studio.

  2. 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.

    Selenium migration gradle

    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.

    Selenium migration build successful

    2.3 Reopen the project to reload all the dependencies.

  3. Copy and paste the source code of your Selenium/TestNG/JUnit project in the Include/scripts/groovy folder of your Katalon project.

    Add TestNG source code

    Add TestND source code

  4. Copy and paste other resources of your Selenium/TestNG/JUnit project in the Include folder of your Katalon project (if any).

    Add TestNG resoureces

  5. To reload the source code and resources from your Selenium/TestNG/JUnit project, right-click the Include folder, then click Refresh.

    Reload TestNG source code and resources

  6. 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.

    Create test case using TestNG/JUnit keywords

    For real-time monitoring and better reporting capabilities, consider integrating your project with Katalon TestOps. See also Enable TestOps integration in Katalon Studio.

See also