---
title: "Export Cucumber Features"
canonical: "https://docs.getxray.app/space/XRAY/301406470/Export%20Cucumber%20Features"
format: markdown
---
> Macro (toc)

  


Cucumber .feature files can be exported from Xray and executed externally. They can be generated from the following Xray issues:

- Test
- Test Set
- Test Execution

Or, from an Issue mapped as a Requirement issue type.

If the **language** defined to export the cucumber .feature files is not the default (i.e., En), then a language tag will be added.

## Rules

Xray generates Cucumber .feature files according to the context issue and the following rules. The global setting "**Generate features by requirements**" affects how feature files are generated. If this setting is disabled, Xray will ignore the connection between Requirements and Tests.

### Considering Requirements associated with Tests ("**Generate features by requirements**" setting is <span style="color: #008000">**enabled**</span>)

##### **<span style="color: #808080">Test</span>**

- A single Cucumber **feature** file is generated for each **requirement** associated with this Test.
- The feature contains the **feature header **description of the associated requirement, if present.
- The feature contains the **background **of the Test, if present in the Pre-Condition associated with it.
- The feature contains the **Scenario/Scenario Outline** defined in this Test.

##### Test Set, Test Execution, Test Plan or Requirement issue

- A single Cucumber **feature** file is generated for each different tuple (**Requirement, Pre-Condition).**
- A Test Execution does not contain repeated tests.
- If a Test is not associated with a requirement, then it will be exported as an independent feature file.
- If a Test is associated with more than one requirement, then a feature file will be generated for each requirement. The generated .feature files will contain repeated test scenarios.
- The feature contains the **feature header **description of the associated requirement, if present.
- The feature contains the common **background **of the Tests, if present in the Pre-Condition.
- The feature contains the **Scenario/Scenario Outline** for all the tests.

### Ignoring Requirements associated with Tests ("**Generate features by requirements**" setting is **<span style="color: #FF0000">disabled</span>**)

##### <span style="color: #808080">Test</span>

- A single Cucumber **feature** file is generated for the Test.
- The feature contains the **background **of the Test, if present in the Pre-Condition associated with it.
- The feature contains the **Scenario/Scenario Outline** defined in this Test.

##### Test Set, Test Execution, Test Plan or Requirement issue

- A single Cucumber **feature** file is generated for each **Pre-Condition. **If there are some Test cases without Pre-Conditions that a **default** feature file will be generated.
- The feature contains the common **background **of the Tests, if present in the Pre-Condition.
- The feature contains the **Scenario/Scenario Outline** for all the tests.

  


## Feature File Format

  


|  |
| --- |
| `[ #language: { language } ]`<br>`[ @{ Test Execution issue Key } ]`<br>`[ @{ Requirement issue Key } ]`  
`Feature: [{ Requirement Issue Summary }]`  
`    ``[{ Requirement Issue Description }]`  
`    `   
`    ``[Background: `  
`        ``{ Pre-Conditions }]`  
`    `   
`    ``[# { Test Issue Description }]`  
`    ``@{ Test Issue Key } `  
`    ``[@{ SubRequirement Issue Key 1 } ... @{ SubRequirement Issue Key N }] `  
`    ``[@{ Test Set Issue Key 1 } ... @{ Test Set Issue Key N }] `  
`    ``[@{ Test Issue Label 1 } ... @{ Test Issue Label N}]`  
`    ``Scenario [Outline]: { Test Issue Summary }`  
`        ``{Test Issue Steps}`  
`    ``...` |

  


## Feature File Naming Convention

  


|  |
| --- |
| `<sequential_id_one_based>[_<issue_requirement_key>][_<issue_precondition_key>]` |

  


## Example

Exporting a Test Execution with the following Tests:

| Key | Requirement | Pre-Condition |
| --- | --- | --- |
| T1 | R1 | C1 |
| T2 | R1 | - |
| T3 | - | C2 |
| T4 | R2 | C1 |
| T5 | R2 | C3 |
| T6 | - | - |
| T7 | R2, R3 | C1 |
| T8 | R2, R3 | - |
| T9 | - | C2 |
| T10 | R1 | C1 |

generates the following **9** feature files when the "**Generate features by requirements**" setting is **<span style="color: #008000">enabled</span>**:

| File | Requirements | Pre-Condition | Tests | Filename |
| --- | --- | --- | --- | --- |
| 1 | R1 | C1 | T1, T10 | 1_R1_C1.feature |
| 2 | R1 | - | T2 | 2_R1.feature |
| 3 | R2 | C1 | T4, T7 | 3_R2_C1.feature |
| 4 | R2 | C3 | T5 | 4_R2_C3.feature |
| 5 | R2 | - | T8 | 5_R2.feature |
| 6 | R3 | - | T8 | 6_R3.feature |
| 7 | R3 | C1 | T7 | 7_R3_C1.feature |
| 8 | - | C2 | T3, T9 | 8_C2.feature |
| 9 | - | - | T6 | 9.feature |

and will also generate the following feature files when the "**Generate features by requirements**" setting is **<span style="color: #FF0000">disabled</span>**:

| File | Pre-Condition | Tests | Filename |
| --- | --- | --- | --- |
| 1 | C1 | T1, T4, T7, T10 | 1_C1.feature |
| 2 | C2 | T3, T9 | 2_C2.feature |
| 3 | C3 | T5 | 3_C3.feature |
| 4 | - | T2, T6, T8 | 4.feature |

## Feature Name

The 'feature name' can be defined in the Xray miscellaneous, and we have the option to choose from the following:

- Requirement Summary (default)
- Requirement Key
- Test Summary
- Test Key

### Examples:

#### Case A: Requirement **REQ-A** with tests **TEST-A**, and **TEST-B,** and  **REQ-B** with test **TEST-A**

#### Case B: **Test-C**  without requirement

#### Case C: TestSet/TestPlan/TestExec with 2 tests TEST-A, TEST-B

  


Expected results when the "**Generate features by requirements**" setting is **<span style="color: #008000">enabled</span>**:

|  | Case A From Requirement | Case A From Test A | Case B | Case C from TestSet/TestPlan/TestExec |
| --- | --- | --- | --- | --- |
| Requirement Key | Requirement Key in each req file | Respective requirement key in each req file | DEFAULT | Respective requirement key in each req file |
| Requirement Summary | Requirement Summary in each req file | Respective requirement summary in each req file | DEFAULT | Respective requirement summary in each req file |
| Test Key | All respective test keys in each req file | Test Key in each req file | TEST-C Key | All respective test keys in each req file |
| Test Summary | All respective test summaries in each req file | Test Summary in each req file | TEST-C Summary | All respective test summaries in each req file |
| Old versions | Requirement Summary in each req file | Requirement Summary in each req file | DEFAULT | Respective requirement summary in each req file |

  


Expected results when the "**Generate features by requirements**" setting is **<span style="color: #FF0000">disabled</span>**:

|  | Case A From Requirement | Case A From Test A | Test A/Test Run | Case B | Case C from TestSet/TestPlan/TestExec |
| --- | --- | --- | --- | --- | --- |
| Requirement Key | REQ-A Key | REQ-A, REQ-B Keys | REQ-A, REQ-B Keys | DEFAULT | REQ-A, REQ-B Keys |
| Requirement Summary | REQ-A Summary | REQ-A, REQ-B Summaries | REQ-A, REQ-B Summaries | DEFAULT | REQ-A, REQ-B Summaries |
| Test Key | TEST-A, TEST-B Keys | TEST-A Key | TEST-A Key | TEST-C Key | TEST-A, TEST-B Keys |
| Test Summary | TEST-A, TEST-B Summaries | TEST-A Summary | TEST-A Summary | TEST-C Summary | TEST-A, TEST-B Summaries |
| Old versions | DEFAULT | DEFAULT | DEFAULT | DEFAULT | DEFAULT |