Skip to content

Import test cases to TestOps from generic CSV file

WARNING

This functionality is available in the tool tom-xxxx starting from release tom-1.2.0-all.

Preconditions

JRE/JDK version

The machine (PC, Mac, or virtual machine) where you run the migration tool must have JRE or JDK version 21 or later installed.

TestOps version

WARNING

MIGRATION AVAILABLE FOR TESTOPS VERSION > 4.26.0

Limitations

CSV file import can process textual data only, meaning, it is not possible to import any attachments even these are referenced in the test cases in the CSV file.

Script execution CLI command example

bash
java -jar tom-1.2.0-all.jar /path/to/config/file/config.json

Important information on scenario structure

There are two ways to import test case scenario data – with or without regular expression usage.

Next sub-sections explain the case when regular expression is required.

Classic scenario structure. No regular expression is needed.

If the test case scenario follows the classic structure, i.e. when a line break means a new step, and a line break with a tab means a sub-step, then you do not need to use a regular expression in your config.

The text below will be interpreted as a test case scenario with 3 steps on the level 1 and several sub-steps on level 2 and 3. Such scenario does not require usage of any regular expression.

text
Open something         // step on level 1
  Check it is opened   // /n and /t → sub-step on level 2
    Check well         // /n and /t/t → sub-step on level 3
    Check again        // /n and /t/t → sub-step on level 3
Do some stuff          // /n → step on level 1
  First                // /n and /t → sub-step on level 2
  Second               // /n and /t → sub-step on level 2
  Third                // /n and /t → sub-step on level 2
Check stuff is done.   // /n step on level 1
  Is first done?       // /n and /t → sub-step on level 2
  Is second done?      // /n and /t → sub-step on level 2
  Is the third done    // /n and /t → sub-step on level 2

Example of a CSV file with classic test case scenario structure

csv
allure_id,name,description,precondition,scenario,expected_result,tested_feature,tested_story,tags,created_by,supervised_by,useful_links,issue_tracker
1123,Test case name is a mandatory parameter One,test described the steps to test very important feature,"database must be created as
CREATE DATABASE opaopa_fried_peanuts;","Start login process
	Launch application
		Navigate to login page
	Enter credentials
		Input username: test_user
		Input password: P@ssw0rd!
	Click login
		User should be redirected to dashboard
Validate dashboard
	Check welcome message
		Message should contain user's name
	Check notifications
		Unread count should be displayed
Interact with sidebar
	Open settings
		Navigate to ""Preferences"" tab
		Ensure dark mode toggle is visible
Logout
	Click on user avatar
		Select ""Log out"" from dropdown
		User should be redirected to login screen",we expec all is okay,Authentication,Successful authentication,"regular, critical",bugs_bunny,duffy_duck,"https://interet.com, https://intranet.com",AE-5

Scenario structure that requires the usage of regular expressions

If your test case scenario does not follow the classic structure, but steps can be identified by a consistent pattern, then you should use a regular expression in the configuration.

WARNING

When using regular expression in your configuration, all resulting steps in the scenario will be on the 1st level.

This is expected behaviour.

Example of a test case scenario with regular expression usage

csv
id;name;description;preconditions;expected_result;status;layer;scenario;tags;links;JIRA;assignees;reviewers;testers;priority;component
8629;"Test Case 1";"Test case description 1";"Preconditions 1";Expected result 1;Qqww!1;UI;Step: describe the step number one Step: describe the step number two Step: describe step number three;smoke,ui;http://goo.gle,https://google.com;TP-1;"john.doe,jane.smith";"alice.reviewer";"bob.tester";"High";"Frontend"

Configuration parameters

General settings

json
{
  "type": "common-csv",                   // Migration type
  "debug": true,                           // Enables debug mode
  "oneByOne": false                        // Import test cases one by one
}

Target system configuration (allureConfig)

json
"allureConfig": {
  "endpoint": "https://testops.something/",  // TestOps instance URL
  "token": "your-api-token",              // API token (required)
  "sslTrustAll": true,                     // Disable SSL validation
  "projectId": 1,                          // Target project ID (required)
  "workflowId": 1                          // Target workflow ID (optional, default: -1)
},
"filesConfig": {
  "path": "/path/to/csv/file/csv-import.csv" // Path to CSV file with test cases
},

CSV parsing configuration

This block defines how your CSV file will be parsed.

INFO

In all fieldMapping configurations,

  • on the left side (key) we specify the name of the attribute on TestOps side
  • on the right side (value) we specify the name of the column in CSV file
json
"commonCsvConfig": {
  "columnSeparator": ";",                // CSV column delimiter (e.g., ; or ,)
  "quoteChar": "\"",                    // Character used to quote values
  "escapeChar": "\\",                  // Escape character, see https://en.wikipedia.org/wiki/Escape_character
  "stepRegexp": "Step\\s+",            // Java flavour regular expression to spit steps
  "fieldMapping": {
    "id": "id",                          // Allure ID — must match an existing test case in the project
    "name": "name",                      // Test case name (required)
    "description": "description",        // Description field (required)
    "preconditions": "preconditions",    // Preconditions field (optional)
    "expected_result": "expectedResult",  // Expected result field (optional)
    "status": "status",                  // Status field (required)
    "tag": "tags",                       // Tags field (optional)
    "scenario": "steps",                // Steps field (required)
    "layer": "layer"                     // Test layer field (optional)
  },

WARNING

  • "id" must be removed from the configuration in vast majority of the cases.
    • If you are importing the data not from the same TestOps project, remove it to avoid wasting your time.
  • "stepRegexp" must be removed if your scenario has classic format

Custom Field mapping

This block defines the mapping for custom and system test case fields.

Prerequisites

  • Required Custom Fields must be created globally before migration.
  • To migrate links to issues in an issue tracker e.g. to Jira tasks, issue tracker integration must be set up in the target project.
  • Custom roles must also exist in the project before migration starts.

Mapping CSV columns to the entities in TestOps

INFO

In all mapping configuration,

  • on the left side (key) we specify the value of the record of the specified column in the source CSV file
  • on the right side (value) we specify the name of an entity defined on TestOps instance side
json
"testLayers": {                     // Mapping for test layers
  "API": "API Tests",
  "UI": "UI Tests"
},
"statuses": {                       // Test case statuses
  "one": "Draft",
  "two": "Active"
},
"tags": {                           // Tags configuration
  "column": "tags",
  "separator": ","
},
"links": {                          // Links configuration
  "column": "links",
  "separator": ","
},
"issues": [                         // Issue tracker mapping
  {
    "column": "JIRA",
    "integrationId": 8,             // Id of the created integration (check Administration → Integrations)
    "separator": ","
  }
],
"customFields": {                   // Mapping for custom fields
  "columnToFieldMap": {
    "priority": "Epic",
    "component": "Feature"
  },
  "separator": ","
},
"roles": {                          // Mapping for custom roles
  "columnToFieldMap": {
    "createdBy": "Owner",
    "teamLead": "Lead",
    "testers": "Tester"
  },
  "separator": ","
}

Working Example

Below is a working example containing a configuration file and test cases in CSV format.
Please review it carefully. Understand the structure of the CSV and how field mappings are configured.

Doing so will help ensure a smooth and successful migration.

Click to see full configuration file example
json
{
  "type": "common-csv",
  "debug": true,
  "oneByOne": false,
  "allureConfig": {
    "endpoint": "https://your-allure-testops.com/",
    "token": "your-token-here",
    "sslTrustAll": true,
    "projectId": 1
  },
  "filesConfig": {
    "path": "/path/to/CSV/file/testCaseExample.csv"
  },
  "commonCsvConfig": {
    "columnSeparator": ",",
    "quoteChar": "\"",
    "escapeChar": "\\",
    "fieldMapping": {
      "name": "name",
      "description": "description",
      "precondition": "preconditions",
      "expected_result": "expectedResult",
      "status": "status",
      "tag": "tags",
      "scenario": "steps",
      "layer": "layer"
    },
    "testLayers": {
      "API": "API Tests",
      "UI": "UI Tests"
    },
    "tags": {
      "column": "tags",
      "separator": ","
    },
    "links": {
      "column": "useful_links",
      "separator": ","
    },
    "issues": [
      {
        "column": "issue_tracker",
        "integrationId": 1,
        "separator": ","
      }
    ],
    "customFields": {
      "columnToFieldMap" : {
        "tested_story": "Story",
        "tested_feature": "Feature"
      },
      "separator": ","
    },
    "roles": {
      "columnToFieldMap" : {
        "supervised_by": "Reviewer",
        "testers": "Tester"
      },
      "separator": ","
    }
  }
}

WARNING

Edit this config file before test migration first!

You can download full config file here

You can download CSV example here

Command for the staring of the java -jar tom-1.2.0-all.jar /path/to/config/file/config.json

Last updated: