---
title: "Generate Cucumber Features"
canonical: "https://docs.getxray.app/space/XRAYCLOUD/44565307/Generate%20Cucumber%20Features"
format: markdown
---
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
- Test Plan

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:

##### **<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 there is no requirement associated then the **feature header **will contain the summary of the test.
- The feature contains the **background **of the Test, if present in the Precondition 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, Precondition).**
- 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. If no requirement is associated then the **feature header** will contain the summary of the Test Set if the test was exported from a single test set or the summary of the Test.
- The feature contains the common **background **of the Tests, if present in the Precondition.
- The feature contains the **Scenario/Scenario Outline** for all the tests.

## Feature File Format

```
[ #language: { language } ]
[ @{ Test Execution issue Key } ]
[ @{ Requirement issue Key } ]
Feature: [{ Requirement Issue Summary } || { Test Set Issue Summary } || { Test 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

The max filename will always be 50 characters without the file extension and will follow the rules below:

### When "Generate features file name using summary" is <span style="color: #3366FF">disabled</span>

If the summary option, in the cucumber options, is disabled:

- and the feature contains a requirement:

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

- and no requirement is present on the feature and there is a small amount of tests:

```
<sequential_id_one_based>[_<issue_test_key_1>,<issue_test_key_2>,...]
```

- and no requirement is present on the feature and there is a large enough amount of tests to exceed the filename limit:

```
<sequential_id_one_based>[_<issue_test_key_1>,<issue_test_key_2>,...][(+[number_of_remaining_tests])]
```

### When "Generate features file name using summary" is <span style="color: #3366FF">enabled</span>

If the summary option, in the cucumber options, is enabled:

- and the feature contains a requirement:

```
<sequential_id_one_based>[_<issue_requirement_summary>]
```

- and no requirement is present on the feature:

```
<sequential_id_one_based>[_<issue_test_summary_1>][(+[number_of_remaining_tests])]
```

Note: Summaries will be truncated to prevent filename from exceeding the 50 character limit.

## Example

Exporting a Test Execution with the following Tests:

| **Key** | **Requirement** | **Precondition** |
| --- | --- | --- |
| 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:

| **File** | **Requirements** | **Precondition** | **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_T3,T9_C2.feature |
| 9 | - | - | T6 | 9_T6.feature |