Menu

Create Test Cases from TestNG or jUnit

PREREQUISITES:

  1. Activate Automation Integration
  2. Install and Register the Automation Host
  3. Install the TestNG or jUnit Plugin
  4. Configure TestNG Agent or Configure jUnit Agent

There are 2 ways to create test cases from TestNG or jUnit: 

  1. Manually create automated test cases in Test Design and input the Automation Content field to correspond to your test class or method
  2. Scan the scripting directory to automatically create the test cases. These test cases will have the Automation Content field values auto-populated based on the class or method

You need to have Create Test Cases permission within your qTest project to create test cases from TestNG or jUnit.

Manually Create Test Cases

Through the UI, create a new Automation Test Case in Test Design:

  • Select a Module and click on New Automation Test Case icon from the top of the left navigation toolbar
  • Right click on an existing module and select New > New Automation Test Case
  • Select a Module and press hot keys Shift + A

In the Test Case page, modify the name and its properties. You may want to define its Test Steps. It is the same as creating a manual Test Case. 

You will need to define the associated test in Automation Content field with the syntax:

  • To associate a test class with a Test Case in qTest: [package_name].[class_name]. Eg: sample.testng.HelloWord
  • To associate a test method with a Test Case in qTest: [package_name].[class_name]#[method_name]. Eg: sample.testng.HelloWord#sayHello

Scan Directory for Test Cases

Our Automation Agents feature the ability to scan and detect tests in your scripting directory and then, automatically create the associated Test Cases in qTest.

On the Agent Configuration Screen, click on Save and Scan button. For more information on the Agent Configuration, check out these articles: Configure TestNG Agent or Configure jUnit Agent

 

Alternatively, select your desired agent and click on its Scan icon

The agent will start scanning your directory. After the process is done, all detected tests are listed out.

  1. You can select to view the result by test Class or Method.
  2. You can filter the result grid by package name or Class/Method name.
  3. By default, the suggested Test Case name is the same as the Class/Method name. You can click and modify it.
  4. Click on the check box on the first column of each row to select which Test Cases to be created.
  5. Click on Create button.

It will take a while to create the Test Cases in qTest. They will be located under module Automation Test Case. You can view the result's summarized information after the process is done.

HINT:

  • If a test class has some test methods, when you create a Test Case from the class, its Test Steps will also be defined and each Test Step will be associated with one test methods.
  • When you create a Test Case from a test method, it will have one Test Step associated with the test method.

IMPORTANT:

  • Field Automation Content is the unique identification of an Automation Test Case. The agents will NOT create 2 Automation Test Cases with the same value in this field.
  • For now, the agents do not support updating your Automation Test Cases.
  • When you define a Test Step for an automation Test Case, there needs to be a matching method in your test script so that the step can be executed.
Subscribe To Our Blog
Powered by Zendesk