You can use the Xray's Test Case Importer to import Tests from a CSV or JSON source file.
The Test Case Importer follows a wizard like interface, guiding you through the process which envolves:
- preparing data (CSV/JSON) beforehand
- submit the data
- choose the destination project along with some global settings
- for CSV, define the mapping of CSV columns <=> fields in Jira
The Test Case Importer is only able to create Test issues. If you wish to create other types of issues, you should use Jira's CSV importer instead. Note that Jira's CSV importer is not able to handle any Xray related semantics though.
Preparing the source file
The CSV source file must follow some simple rules.
You can name the fields as you wish since they are going to be mapped during the importation process, but there are three mandatory fields:
- Test ID – this is the field used to identify which lines belongs to which test case.
- Summary – this field is mandatory since Jira doesn’t allow you to create an issue without a summary.
- Test Type – this field defines the Test type of the each test to import. The
Test Typemust match one of the types of the project to which the test is being imported.
Here is an example of a source file as seen in a spreadsheet application:
Here is the same example as seen in a text editor:
Importing into multiple projects
The tests can all be imported to the same project or into multiple projects, one column in the source file can be used to define the destination project (either by having its key or id).
CSV column delimiter
If you choose the "," (comma) as the CSV column delimiter, then you must use quotation marks around any field that contains commas. The same is true if you use ";" (semicolon) as a delimiter and you want to use them in a field, for example as a list value delimiter (see the example above).
Fields with line breaks
If you need to use new lines within a field, for example, in the issue description, then you need to quote the field.
Go to the "Xray" menu and then Select "Test Case Importer" and the select the CSV file format:
File Import step
Provide the source file and settings regarding the file.
- The file encoding used in the CSV source file, this is especially important when the file contains non ASCII characters.
- The CSV delimiter is the column delimiter used
Aditional setup information, for choosing the destination project along some settings related with the source data.
- The default project to which the tests will be imported into. Tests without project information associated will be imported into the project defined by this field.
- The list value delimiter is the delimiter used for fields that are lists of values.
- Date format used to parse the fields that are representing dates, refer to this page for help on how to define a valid format.
- Flag indicating if Test Repository folders should be created automatically if they do not exist.
Map fields step
During this step, you'll define the mapping of columns to Jira/Xray fields.
There are two mandatory fields that must be mapped: Summary and Test Type.
Besides these ones, if you have defined additional fields as mandatory for Test issues, then you will also need to specify their mapping.
The project to which the test will be imported can be defined for each test in a field. The fields "Project Key" or "Project Id" can be used for this.
If no project field is mapped or when the value in this field is empty, the project selected in the Setup step will be the one where these tests will be imported into.
Test Repository Folder field
The Test Repository folder path to the folder in which the Tests will be associated.
The folder path consists of folder names separated by the "/" character, for example: Main Tests/Sub Tests 1/Inner Tests 2
A link can be created between imported tests and other existent issues using the "Link ..." Jira fields.
The value of the respective field should hold the issue key for the required issue to link to the test.
The direction (inward/outward) can also be specified.
Datetime fields must have values that can be parsed using the Datetime format in the Setup step.
This page explains possible date formats and respective values.
List fields can hold multiple values separated by the list delimiter defined in the Setup step.
After this step the import process will start.
Preparing the source file
The JSON source file must have the same structure as the one used in the import through the REST API.
Example of one test in the JSON import format:
To import tests using a JSON source file, you must choose the JSON file format in the Test Case Importer.
File Import step
Choosing the file to import.
Choosing the default project to import into. If each test to import already refers to a project, this field is not necessary to be filled, otherwise you should choose a project.
Results of the import process
After the import process has began its status will be periodically updated in the Test Case Importer page. No new import process can be started until the current one finishes.
After the process finishes the result will be visible for about a day and then it will be removed from the page.
Example of 999 tests imported successfully:
You may also download the detailed import results, this is useful to get the issue keys of the imported test issues and also to see which tests were not imported and why.
Example of 2 tests imported out of 4:
Detailed import result for the example above:
In the detailed import result, the
elementNumber field represents to which test the information corresponds (elementNumber 0 being the first test).
When importing into Test Repository folders, if for any reason the process is unable to create a folder or move a test to the respective folder, the respective tests will be still be migrated and a warning detailing the situation will be written to the import result.