Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following endpoint is provided to import a Cucumber .feature file or a zip file containing multiple .feature files. The files in the zip file may be in folders/subfolders.

In addition to the .feature or a zip file the endpoint also accepts a JSON file which can specify additional information that will be added to the Test or Precondition at the moment of their creation. The format of JSON where additional information for the Test and Precondition can be specified is similar to the one Jira uses to create/update issues, for more information about the format, check the Jira documentation here.

Cucumber ".feature" file/api/v1/import/feature

...

Each .feature file will be processed and will try to find or create a Test/Pre-Condition inside the project given in the projectKey parameter. We use the following rules:

Tests:

  1. If Test key is present in the file:
    1. exists in Jira, system tries
    try
    1. to find the Test by key
    , if present then
    1. and update it; else...
    2. does not exists in Jira, system returns an error message.
  2. If Test key is not present in the file, system tries try to find the Test having:
    1. the same source and original relative path of .feature (e.g. "[project_lambda]core/sample_addition.feature) and
      1. same ID (extracted from a scenario label named id:xxx) or
      2. same summary; else...
    2. the same summary in the target project; else...
    3. create Test in that project. The tags used in the scenario/scenario outline are also added as labels.

Pre-Conditions:

  1. If Pre-Condition is present in the file:
    1. exists in Jira, system tries
    try
    1. to find the Pre-Condition by key
    , if present then
    1. and update it; else..
    .
    1. .
    2. does not exist in Jira, system returns an error message.
  2. If Pre-Condition key is not present in the file, system tries try to find the Pre-Condition having:
    1. the same source and original relative path of .feature (e.g. "[project_lambda]core/sample_addition.feature); else...
    2. the same summary in the target project; else...
    3. create Pre-Condition in that project. The tags used in the background are also added as labels.

The mapping from the Scenario/Scenario Outline present in the .feature files to the Test issues in Jira would be as follows:

...

Code Block
@REQ_CALC-889
Feature: As a user, I can calculate the sum of 2 numbers     
       
	Background:
		#@PRECOND_TX-114
		Given that the calculator is turned on
		And the mode is to advanced
		#@PRECOND-_TX-155
		Given that the calculator has been reset

	@UI @core
	Scenario Outline: Cucumber Test As a user, I can calculate the sum of 2 numbers
		Given I have entered <input_1> into the calculator
		And I have entered <input_2> into the calculator
		When I press <button>
		Then the result should be <output> on the screen
	
		  Examples:
		    | input_1 | input_2 | button | output |
		    | 20      | 30      | add    | 50     |
		    | 2       | 5       | add    | 7      |
		    | 0       | 40      | add    | 40     | 
		    | 4       | 50      | add    | 54     |

...

Expand
titlePOST /api/v1/import/feature
Panel
borderColor#ccc
borderStylesolid

Request

QUERY PARAMETERS

parameter

type

description

projectKeyString

key of the project where the tests and pre-conditions are going to be created.

projectIdStringid of the project where the tests and pre-conditions are going to be created.
sourceStringa name designating the source of the features being imported (e.g. the source project name)

multipart/form-data:

"file" : a MultipartFormParam containing a ".feature" file or a ZIP file to import.

"testInfo" : a MultipartFormParam containing a JSON file with extra Test information. (optional)

"precondInfo" : a MultipartFormParam containing a JSON file with extra Precondition information. (optional)

Tip
titleExample Request

curl -H "Content-Type: applicationmultipart/jsonform-data" -X GET POST -H "Authorization: Bearer $token" -F "file=@1.feature" https://xray.cloud.xpand-itgetxray.comapp/api/v1/import/feature?projectKey=DEMO

curl -H "Content-Type: applicationmultipart/jsonform-data" -X GET POST -H "Authorization: Bearer $token"  -F "file=@features.zip" https://xray.cloud.xpand-itgetxray.comapp/api/v1/import/feature?projectId=1000

curl -H "Content-Type: applicationmultipart/jsonform-data" -X GET POST -H "Authorization: Bearer $token"  -F "file=@features.zip" https://xray.cloud.xpand-itgetxray.comapp/api/v1/import/feature?projectId=1000&source= project_lambda

curl -H "Content-Type: multipart/form-data" -X POST -H "Authorization: Bearer $token" -F "file=@1.feature" -F "testInfo=testInfo.json" -F "precondInfo=precondInfo.json" https://xray.cloud.getxray.app/api/v1/import/feature?projectKey=DEMO

Responses

200 OK : application/octet-stream : Successful. The cucumber features where successfully imported to Jira.

Code Block
titleExample Output
{
    "errors": [
		"Error in file calculator.feature: Precondition with key DEMO-54321 was not found!"
	],
    "updatedOrCreatedTests": [
        {
            "id": "32495",
            "key": "DEMO-15119",
            "self": "https://devxray3.atlassian.net/rest/api/2/issue/32495"
        },
        {
            "id": "32493",
            "key": "DEMO-15117",
            "self": "https://devxray3.atlassian.net/rest/api/2/issue/32493"
        }
    ],
    "updatedOrCreatedPreconditions": [
		{
            "id": "12345",
            "key": "DEMO-12345",
            "self": "https://devxray3.atlassian.net/rest/api/2/issue/12345"
        }
	]
}


400 BAD_REQUEST : text/plain: Returns the error.

401 UNAUTHORIZED : text/plain : The Xray license is not valid.

500  INTERNAL SERVER ERROR : text/plain : An internal error occurred when generating the feature file(s).