This extension is designed to help developers using the testing framework with Gherkin style feature files to generate step definition more easily and efficiently. With just a few clicks, you can automatically generate step definition for your feature files, saving you time and reducing the risk of errors.
If you find this extension useful for your projects, please consider supporting me by Github, Patreon, KO-FI or Paypal. It's a great way to help me maintain and improve this tool in the future. Your support is truly appreciated!
Get it from Visual Studio Marketplace or Open VSX Registry.
DataTable
, DocString
, int
, float
, string
, and other types of information that are supported by Gherkin Syntax.You have multiple options when it comes to generating step definition using this extension:
Generate step definition to file
Generate step definition to clipboard
{
// Change the testing framework used for step deinitions
"step-definition-generator.runner": "cypress",
// Change the programing language used for step deinitions
"step-definition-generator.language": "typescript",
// Choose to generate step definitions using either arrow or regular functions.
"step-definition-generator.arrow": true,
// Choose to generate step definitions using either async or sync functions.
"step-definition-generator.async": false
}
@web @regression
Feature: Search functionality
As a user,
I want to be able to search for products on the website,
So that I can find what I need quickly and easily.
Background:
Given I am on the home page
And I am logged in as "user@example.com"
Rule: Search by keyword
Scenario: Search with a valid keyword
When I enter "laptop" in the search bar
And I click the search button
Then I should see a list of products containing "laptop"
And the total number of results should be 10
Scenario Outline: Search with invalid keyword
When I enter <keyword> in the search bar
And I click the search button
Then I should see an error message
Examples:
| keyword |
| 12345 |
| $%^&* |
| "invalid" |
Rule: Search by category
Scenario: Search for a specific category
When I select "Electronics" from the category dropdown
And I click the search button
Then I should see a list of products in the Electronics category
And the total number of results should be a float value between 10.0 and 20.0
Scenario Outline: Search with multiple categories
When I select the following categories:
| category |
| Electronics |
| Clothing |
And I click the search button
Then I should see a list of products in the selected categories
And the total number of results should be an integer value
Rule: Search with filters
Scenario: Search with filters applied
When I select "Brand A" from the brand filter
And I select "Price > $100" from the price filter
And I click the search button
Then I should see a list of products that match the applied filters
And the total number of results should be greater than 0
Rule: Search with docstring and datatable
Scenario: Search with advanced options
When I click the "Advanced Search" link
And I fill in the following information:
"""
{
"category": "Electronics",
"brand": "Brand B",
"priceRange": [
50,
100
],
"features": [
{
"name": "WiFi",
"value": "Yes"
},
{
"name": "Bluetooth",
"value": "No"
}
]
}
"""
And I click the search button
Then I should see a list of products that match the advanced search criteria
And the total number of results should be a float value
@smoke
Scenario: Search withno keyword
When I click the search button without entering a keyword
Then I should see the home page with no search results displayed
import { Given, When, Then, DataTable } from '@badeball/cypress-cucumber-preprocessor';
Given(`I am on the home page`, () => {
// [Given] Sets up the initial state of the system.
});
Given(`I am logged in as {string}`, (arg0: string) => {
// [Given] Sets up the initial state of the system.
});
When(`I enter {string} in the search bar`, (arg0: string) => {
// [When] Describes the action or event that triggers the scenario.
});
When(`I click the search button`, () => {
// [When] Describes the action or event that triggers the scenario.
});
Then(`I should see a list of products containing {string}`, (arg0: string) => {
// [Then] Describes the expected outcome or result of the scenario.
});
Then(`the total number of results should be {int}`, (arg0: number) => {
// [Then] Describes the expected outcome or result of the scenario.
});
When(`I enter {any} in the search bar`, (arg0: any) => {
// [When] Describes the action or event that triggers the scenario.
});
Then(`I should see an error message`, () => {
// [Then] Describes the expected outcome or result of the scenario.
});
When(`I select {string} from the category dropdown`, (arg0: string) => {
// [When] Describes the action or event that triggers the scenario.
});
Then(`I should see a list of products in the Electronics category`, () => {
// [Then] Describes the expected outcome or result of the scenario.
});
Then(`the total number of results should be a float value between {float} and {float}`, (arg0: number, arg1: number) => {
// [Then] Describes the expected outcome or result of the scenario.
});
When(`I select the following categories:`, (arg0: DataTable) => {
// [When] Describes the action or event that triggers the scenario.
// <DataTable> argument is detected:
// - With column headers: use DataTable.rowsHash(), which outputs an object containing key-value pairs for each row (e.g. { key1: value, key2: value }).
// - With row headers: use DataTable.hashes(), which outputs an array of objects (e.g. [{ key1: value, key2: value }]).
});
Then(`I should see a list of products in the selected categories`, () => {
// [Then] Describes the expected outcome or result of the scenario.
});
Then(`the total number of results should be an integer value`, () => {
// [Then] Describes the expected outcome or result of the scenario.
});
When(`I select {string} from the brand filter`, (arg0: string) => {
// [When] Describes the action or event that triggers the scenario.
});
When(`I select {string} from the price filter`, (arg0: string) => {
// [When] Describes the action or event that triggers the scenario.
});
Then(`I should see a list of products that match the applied filters`, () => {
// [Then] Describes the expected outcome or result of the scenario.
});
Then(`the total number of results should be greater than {int}`, (arg0: number) => {
// [Then] Describes the expected outcome or result of the scenario.
});
When(`I click the {string} link`, (arg0: string) => {
// [When] Describes the action or event that triggers the scenario.
});
When(`I fill in the following information:`, (arg0: string) => {
// [When] Describes the action or event that triggers the scenario.
// <DocString> argument is detected:
// - DocString allows for passing a multi-line string as an argument.
// - It can also be used to provide large amounts of text data, such as JSON or XML payloads.
});
Then(`I should see a list of products that match the advanced search criteria`, () => {
// [Then] Describes the expected outcome or result of the scenario.
});
Then(`the total number of results should be a float value`, () => {
// [Then] Describes the expected outcome or result of the scenario.
});
When(`I click the search button without entering a keyword`, () => {
// [When] Describes the action or event that triggers the scenario.
});
Then(`I should see the home page with no search results displayed`, () => {
// [Then] Describes the expected outcome or result of the scenario.
});
If you discover a bug, or have a suggestion for a feature request, please submit an issue.
This extension is licensed under the MIT License