Importing Cucumber Tests


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.

Cucumber ".feature" file/rest/raven/1.0/import/feature


Each .feature file will be processed as follows:

  • The "Scenario" or "Scenario Outlines" should be imported to Tests, of the Test Type "Cucumber", with the respective Cucumber Type filled out.
  • A Test will be uniquely identified by the name of the test case that follows the "Scenario/Scenario Outline" sections. Therefore, if a test is found with the same name, then it will be updated; otherwise, a new Test will be created in Jira.


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

Scenario/Scenario OutlineTest in JIRA
name of the Scenario/Scenario Outline"Summary" field
steps"Scenario" field
tags of the Scenario/Scenario Outlinelabels


The "Feature" section is not imported, since the feature itself should exist previously as a Jira requirement issue (e.g., story).

The exception is the tags before the "Feature: " section; if a requirement issue is found for the specified key, then a "Tests" link is created between the Test and the requirement issue.

If the Cucumber feature has a background, a Pre-Condition issue will be created containing the information provided in that background. If the background has no name, then the Summary of the Pre-Condition is going to be a string containing the keys of the Tests of that Cucumber feature.

Below is an example of a .feature file containing a Scenario Outline:


@REQ_CALC-889

Feature: As a user, I can calculate the sum of 2 numbers

        @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     |


Request

QUERY PARAMETERS

parameter
type
description
projectKeyString

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

multipart/form-data:

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

Example Request

curl -H "Content-Type: multipart/form-data" -u admin:admin -F "file=@1.feature" http://yourserver/rest/raven/1.0/import/feature?projectKey=DEMO

curl -H "Content-Type: multipart/form-data" -u admin:admin -F "file=@features.zip" http://yourserver/rest/raven/1.0/import/feature?projectKey=DEMO

Responses

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

Example Output
[
	{
		"id":"14400","key":"DEV-915","self":"http://localhost:8727/rest/api/2/issue/14400"
	}
]


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

  • No labels