Import and Create Test Cases Using BDD Feature File

Introduction

supports importing test cases via a BDD feature file. This approach effectively ensures software behaves as expected while fostering clear communication and collaboration among all team members. By using Gherkin syntax in feature files, teams can write tests that are simple to understand, easy to maintain, and straightforward to execute, resulting in a seamless and efficient testing process.

Benefits of Using BDD Feature Files to Import Test Cases

  • Improved Collaboration: Writing tests in plain language fosters better collaboration between business analysts, developers, and testers. Everyone can understand the tests, regardless of their technical expertise.

  • Clear Specifications: Feature files provide clear and concise documentation of the expected system behavior. These can serve as living documentation that evolves alongside the software.

  • Automation: Once the feature files are defined, they can be used for automated regression testing, ensuring the system continues to behave as expected over time.

  • Reduced Miscommunication: Because the tests are written in natural language, misunderstandings and miscommunications between stakeholders are minimized.

  • Test Reusability: Steps defined in feature files can be reused across multiple scenarios, leading to cleaner and more maintainable tests.

Note

Pre-requisite: To display the BDD section on the Story issue page in Jira, the BDD Panel option should be enabled in the Project Settings. Refer to BDD in QMetry Test Management for Jira (QTM4J) for more details on configuring BDD and enabling the BDD panel.

Required Permissions: The following table shows permissions needed to perform the corresponding operations.

Operation

Required Permissions

Import Test Case

  • Import permission

  • Test Case View

  • Test Case Create

  • Test Case Edit And Archive

Update Test Case

  • Test Case View

  • Test Case Edit And Archive

Link Test Case

  • Test Case View

  • Test Case Edit And Archive

Link Requirement

  • Test Case View

  • Requirement View

  • Requirement Edit

Add Labels

  • Configuration View

  • Configuration Modify

Parameter

  • Configuration View (for reusing existing parameters)

  • Configuration Modify (for creating new parameters)

Business Rules

  • The files with the following attributes are supported:

    • Format: .feature files

    • File Size: Files with a total size of up to ten MB, with each file having a maximum size of one MB

    • Limit of Number of Files: Individual files up to a maximum of ten files

  • You can reuse the test cases using the Test Case Key. The latest version of the test case that matches the Test Case Key is updated.

  • You can link the requirements to test cases using the Story Key. The test case version is linked to the mentioned Story Key.

  • When the feature file is imported from the Test Case list view, the Examples in the feature file become the @Parameters in steps, and variables become Parameters.

Note

Mapping of Feature File with QTM4J Fields for Import

The following table displays the mapping of the feature file with QTM4J fields.

Scenario

QTM4J Test Case Mapping

Example/Note

Scenario Name

Test Case Summary

NA

Feature Name

Description

NA

Steps

Test Steps

Includes Keyword and Step

Data Table in Steps

Steps Summary

| username | password |

| validUser | invalidPass |

| invalidUser | validPass |

| validUser | validPass |

Docstrings in Steps

Steps Summary

""" { "username": "validUser", "password": "validPass" } """

Tags

Labels

The tags at the Feature File level and at the Scenario/Outline level will be added as labels.

@testcasekey

Test Case Key

When importing the feature file, test cases can be reused by adding an annotation to the file.

  • If the specified key exists in QTM4J, the test case will be updated with changes in the feature file.

  • Multiple test case keys (i.e. testcasekey) can be defined for a single scenario, which will update/create multiple test cases for that single scenario. For example, the test case keys can be mentioned in tags as follows.

    Multiple Test Case Keys

@storykey

Jira Requirements

When importing the feature file, existing Jira stories can be reused by adding an annotation to the file.

  • If the specified Story Key exists in Jira, the test case will be linked to that Story.

  • The Story Key for cross-project is also supported during import.

  • The story linkage depends on the level at which the Story Key is mentioned:

    • Feature Level: All test cases created from the scenarios will be linked to the story.

    • Scenario Level: The test case that is created from the scenario will be linked to the story.

  • If the Story Key is invalid or not found, the Story linkage will not happen.

  • Multiple story keys (i.e. storykey) can be defined to link with the test case. For example, the story keys can be mentioned in tags as follows.

    Multiple Story Keys

Background Steps (Scenario Level)

Steps

These Background steps will be added as initial steps of the test case created from the scenario.

Background Step (Feature File Level)

Steps (i.e., initial steps of all test cases)

These Background steps will be added as initial steps of all the test cases created from the scenarios under the Feature.

Rule

Description

The first line of the Rule will be appended to the Description of the test case, along with the Feature name, separated by a semicolon ( ;).

Examples (Scenario Outline)

Parameters

Examples will become the @Parameters in Steps.

Variables will be Parameters in the Test Data.

If duplicate parameter values exist in the .feature file, they will be created as a single value under Configuration > Parameters and will be reused under Test Case > Steps tab > Parameters section.

Sample Files

Sr. No.

File Content

Download Sample File

1

Feature File with multiple scenarios

Multiple Scenarios.feature

2

Feature File with Scenario Outline

Scenario Outline.feature

3

Feature file with Scenario and Scenario Outlines

Scenario and Scenario Outlines.feature

4

Feature file with Rule, Rule Example Cases

Rule Example Cases.feature

5

Feature file with Rule, Scenario Cases & Background

Rule Scenario Cases Background. feature

6

Example for Table Data and Doc String

Table Data Doc String.feature

Best Practices

The following are some of the best practices for writing BDD feature files to import test cases, which help you ensure clarity, maintainability, and reusability of your BDD test cases.

  • Use Scenario Outline for data-driven tests with multiple input sets via Examples.

  • Keep scenarios focused on one behavior per test case.

  • Use clear, descriptive names for features, scenarios, and steps.

  • Group related scenarios together and use Background for shared steps.

  • Tag scenarios (e.g., @smoke, @regression) to label and categorize tests.

  • Write from the user’s perspective using simple, understandable language.

  • Ensure scenario independence to improve test reliability.

  • Refactor regularly to keep feature files clean and maintainable.

Feature Availability

You can access the feature from the following modules and pages:

  • Import Feature File in Test Case Module

  • Create New Test Cases from Jira Story > BDD section

  • Create a New Test Case Using Scenario in Test Case Module

  • Update an Existing Test Case Using Scenario in Test Case Module

Import Feature File

Import Feature File in Test Case Module

Testers can import test cases from the BDD feature files, where each Scenario or Scenario Outline or Example in the feature file represents an independent test case.

Perform the following steps to import feature file:

  1. Go to the Test Case module.

  2. Click the Import drop-down list and select the Feature File option.

    The Import Test Cases from the Feature File screen appears.

  3. Select the From Feature File tab.

  4. To upload the .feature file, either select the file by clicking on the link or drop the file to the designated area.

    A new record appears when you attach the .feature file. All the system and custom fields display on the screen.

  5. In the Import Settings, define the test case fields and select the import options for the Test Case Key and Labels.

    Summary, Description, and Steps values are imported automatically from the .feature file.

  6. Select values for any remaining system fields and custom fields displayed on the screen.

    Note

    The selected fields apply to all test cases created from the feature file. Your selection is saved for future imports.

  7. Select the required option for the following Import Options:

    • If a Test Case Key is found for a scenario: If the Test Case Key mentioned in the result file matches the Test Case Key in QTM4J, you can select either of the following options:

      • Update the current version: The existing version of the test case is updated with the result file details.

      • Create a new version: A new version of the test case is created with the result file details.

    • Tags are imported as labels. If labels do not exist, then click Create or Ignore.

      • Create: If the Tags mentioned in the result file do not exist in , they are imported as labels in the Configuration section and applied to the test case Labels field.

      • Ignore: If the Tags mentioned in the result file do not exist in , they are not imported into QTM4J and just ignored.

  8. Click Import.

    Import Dialog

View Import Progress

Perform the following steps to view the import progress:

  1. Click the Test Case Import/Create Background Jobs tab.

    You can see the record is added for the recent feature file import.

    The details include Batch Id, Source, File Name, Status, Import Date, and Imported By.

  2. Expand the record to view the details of Scenarios imported during the operation, Test Case Keys to which the scenarios were mapped, version, and Status.

View Import Progress

Verify Created Test Cases

The system imports scenarios from the feature file as test cases into the selected folder. If you don't select a folder, it imports them into the root folder.

Verify Test Cases

See Also,

Create and Update Test Cases Using Feature File

Publication date: