Back to QMetry All Products Help Page
Create or Update Test Cases Using BDD Feature File
Overview
Behavior-Driven Development (BDD) is a software development approach that uses natural language to define expected behavior. It helps ensure the software works as intended and improves collaboration through a shared understanding of requirements.
Behavior-Driven Development (BDD) improves collaboration and ensures clarity in software expectations. QMetry allows importing test cases from .feature files following Gherkin syntax, enabling users to create or update test cases from different modules:
From the Requirement module (BDD section)
From the Test Case module
Directly while creating or updating a test case
Permissions Required
The following table lists the permissions required for each operation:
Operation | Required Permissions |
|---|---|
Import Test Case | Import, Test Case View, Create, Edit and Archive |
Update Test Case | Test Case View, Edit and Archive |
Link Test Case | Test Case View, Edit and Archive |
Link Requirement | Test Case View, Requirement View and Edit |
Add Labels | Configuration View and Modify |
Parameter | Configuration View (reuse), Modify (create) |
File Requirements
Supported file:
Format:
.featurefilesSize: 10 MB
Import Limit: 1 file or a ZIP file with up to 10
.featurefiles.
The feature is tested within the Cucumber framework.
To learn more about the parsing guidelines, refer to
Reference | Cucumber.
Mapping of Feature File with QTM Fields for Import
The following table lists the mapping of the feature file with QTM fields:
Scenario | Mapping | Example/Note |
Scenario Name | Test Case Summary | It can be a Scenario, Scenario Outline, or Example. |
Feature Name | Test Case Description | - |
Scenario Steps | Test Steps | Includes Keyword and Step Supported Gherkin Keywords
|
Data Table in Steps | Steps Summary |
|
Docstrings in Steps | Part of Step Description in Steps |
|
Tags | Labels
| Tags are added as labels. |
@testcasekey | Test Case Key | If the specified key exists in QTM, the system creates a new version of the test case with updates from the feature file. You can define multiple test case keys for a single scenario.
|
@requirementkey | Requirements |
|
Background Steps (Scenario Level) | Steps | Gets added as initial steps of the test case. |
Background Step (Feature File Level) | Steps - before all the scenario steps i.e Initial Steps of all Test Cases | Gets added as initial steps for all test cases created from the Feature file. |
Rule | Description | Appends to Description along with feature name separated by |
Examples (Scenario Outline) | Parameters | The values listed in the Examples table becomes @Parameters in the test steps and variables becomes Parameters. Parameter and Value Handling
|
Sample Files
Sr. No. | File Content | Download Sample File |
|---|---|---|
1 | Feature File with multiple scenarios |
|
2 | Feature File with Scenario Outline |
|
3 | Feature file with Scenario and Scenario Outlines |
|
4 | Feature file with Rule, Rule Example Cases |
|
5 | Feature file with Rule, Scenario Cases & Background |
|
6 | Example for Data Parameters under Table Data |
|
Import Options
During import, the system processes test cases and labels based on the import option selection:
Test Case Key Handling
If a Test Case Key is specified:
Update Current Version
Updates the existing version of the test case.
Applicable only to test cases that are unarchived, not executed, and not approved.
Create New Version
Adds a new version to the existing test case.
Applicable only to unarchived test cases.
Label Handling
If the specified labels are not found in the project, user can choose to:
Create: Adds labels to Configuration and applies them to the test case.
Ignore: Skips missing labels.
Note
Import fails for archived, approved, or executed test case keys.
To create new “Labels” you need “Modify Label” permissions.
Methods to Import and Create Test Cases From a BDD Feature File
A. From the Requirement Module (BDD Section)
You can create test cases from a feature file or Gherkin syntax in the BDD section of the Requirement module.
Note
Configure the BDD section under BDD Configuration tab in Project Settings.
To create test cases from BDD section in requirement module, perform the following steps:
Open the Requirement details page.
Go to the BDD section.
Sync the feature file with the Source Control repository.
Select the feature files associated with the requirement to create test cases.
Fill system and custom fields.
Choose import options for Test Case Keys and Labels.
Click Create.
The system automatically redirects to the Background Task screen, where you can monitor the import progress. It displays details such as Source ID, File Name, Job Status, Test Case Key, Data Grid, and Failure Reason (if any).
Notes
All imported test cases will inherit the selected field values.
Your preferences are saved for future imports.
B. Import Feature File from Test Case Module
You can create BDD test cases by importing a feature file directly from the Test Case module. BDD configuration is not required for this import.
To import test cases from a feature file from the test case module, perform the following steps:
Go to the Test Case module.
Click the cog icon and select Import from Feature File.
Upload a file.
Fill in the required details.
Select Import Options for Test Case Key handling and labels.
Click Create.
After clicking Create, the system redirects to the Background Jobs section, where you can monitor the import status.
Once the import is complete, expand the entry to view test case details. In case of a failure, expand to view the error details.
C. Create or Update Test Cases using BDD Syntax
You can directly create or update test cases by pasting the Gherkin syntax from a feature file.
Updating an Existing Test Case
You can reuse a test case by updating it with new Gherkin syntax from a feature file.
To update an existing test case from a feature file, perform the following steps:
Open an existing test case.
Click Scenario.
Paste the BDD content.
Here you can choose either:
Update Current Version
Create New Version
Clicking on Create New Version keeps the current version and creates a new one with updated details.
Clicking on Update Current Version overrides and replaces the existing Summary, Description, and Steps with the new details from the feature file.
Creating a New Test Case
Use this option to create a new test case scenario from feature file.
To create a new test case from a feature file, perform the following steps:
Click New and select Scenario.
Enter a scenario from a feature file and click Import to create the test case.
Fill in all mandatory fields and enter the required test case details.
Click Create.
A new test case is created in the specified folder. If no folder is specified, the test case is created in the root folder.
Notes
When creating or updating a test case using a
ScenarioorScenario Outline:The Scenario name is used as the Test Case Summary.
The Steps are mapped to Test Steps.
Any Data Tables or Doc Strings within steps are added to the Step Description.
Only the fields listed above are supported.
Tags, Test Case Keys, and Requirement Keys are not supported in this method.
Known Limitations
When importing test cases from BDD .feature files authored in Cucumber, please note the following limitations:
Gherkin Keywords Are Not Displayed
The system does not display step keywords such as
Given,When,Then,And,*, in the imported test steps.
Data Tables and Doc Strings Not Captured
The system does not support import of data tables and doc strings used within steps into the step description.
Background Steps Not Imported
Backgroundsteps defined in the feature file are currently not imported into the test case.You need to add these common setup steps manually, if required.
Note
Review and manually adjust the imported steps if these elements are critical to their test scenarios.
Back to QMetry All Products Help Page