Design the TestsBehavior-Driven Development (BDD) Compliant Feature Files

Behavior-Driven Development (BDD) Compliant Feature Files

The algoQA platform adheres to the behavior-driven development (BDD) framework for generating Feature Files. These files are text documents used to describe specific functionalities of your application that require testing, written in the Gherkin-based language. Test cases are generated in English, similar to the Gherkin language. Gherkin's plain-text format allows users to describe an application's behavior by outlining scenarios and steps in a language that's easy to understand.

Understanding Feature Files Generated in the Gherkin-Based Language

In the algoQA platform-generated Feature File, it is important to understand the Gherkin syntax, which is the language used for describing an application’s behavior in plain English.

Gherkin has a simple syntax that includes the following key elements:

ElementDescription
FeatureDescribes the overall feature that is being tested
Scenario NameDescribes a specific situation or test case within the feature
Test case tagsAllows tagging of scenarios to group them based on their purpose or functionality
Scenario OutlineProvides a brief test case summary or description as an outline given during recording of the scenario using Follow Me feature
GivenDescribes the initial state of the user for a given scenario
WhenDescribes the action of the user or event that triggers the behavior being tested
ThenDescribes the expected outcome or result of the scenario
AndAllows you to add additional Given, When, or Then statements to a scenario
ButAllows you to add an exception or negative case to a scenario
ExamplesAllows you to define a set of inputs and expected outcomes in a tabular format

Example

Consider a scenario where currency is to be verified for various countries. During profiling, configure the country and currency. This can be done in the Test Design screen by clicking it.

The algoQA-generated Feature File:

Feature file scenario outline for currency verification with Examples table for India and USA

Best Practices for Creating Feature Files

To create feature files that effectively describe the behavior of your application and are easy to understand, follow these best practices:

  • Use meaningful and descriptive feature names, scenario names, and scenario outlines. Use personas to describe scenarios and scenario outlines.
  • Include multiple verification steps in each scenario to thoroughly test the behavior of the system. This ensures that the expected outcomes are met and helps identify any discrepancies or issues.
  • Instead of using hardcoded wait times in your tests, consider using dynamic wait actions. This allows the tests to wait for elements to become available before performing actions.
  • When verifying the state of elements on the page, use the "Verify content" action instead of the "Verify display" action.
  • Use tags to organize and group scenarios for performing batch execution, which reduces execution time.