/
Import and Create Test Cases Using BDD Feature File

Import and Create Test Cases Using BDD Feature File

Introduction

QTM4J supports importing test cases via a BDD feature file. It is an effective approach to ensuring 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.

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 required to perform the corresponding operations.

Operation

Required Permissions

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 10 MB, with each file having a maximum size of 1 MB

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

  • Test Cases can be reused using the Test Case Key. The latest version of the test case that matches the Test Case Key will be updated.

  • Requirements can be linked to test cases using the Story Key. The test case version will be linked to the mentioned Story Key.

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

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.

image-20241216-073550.png

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

image-20241216-072208.png

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