More quality in your software: using AI to facilitate BDD creation and review

Image for the blog post using AI to facilitate Behavior-Driven Development (BDD) creation and review. A software developer typing code on a screen with a dark background, this person is on their back, has white skin and long, straight black hair.
Find out how StackSpot AI can simplify and expedite your efforts to write and improve Behavior-Driven Development (BDD).

If you’ve ever ventured into test automation or sought to simplify the definition of your software’s business rules, you’ve probably come across the Gherkin language for writing BDD (Behavior-Driven Development).

This language is a key component in the context of BDD for automation, as it facilitates the standardization, documentation, and reuse of code and functionalities, aligning them with business rules when writing tests.

In this article, you’ll find out how StackSpot AI can simplify and expedite your efforts to write and improve BDDs.

What is BDD?

Behavior-Driven Development is a methodology focused on improving team communication by adopting practices that describe software behavior in an agile and straightforward way. 

BDD fosters collaboration between business, development, and quality teams, helping them share ideas and overcome the challenge of making tests and the software itself easier to understand.

BDD was introduced in 2000 by Dan North. Learn more about this technique in this article.

Now that you know what BDD is, it’s time to see how StackSpot AI can simplify this process.

How StackSpot AI supports BDD creation

Although the Gherkin language follows a structured pattern of steps and keywords — which must be based on business rules — how the BDD is written can vary according to the experience of the individual responsible for writing it.

This is where the “magic” of StackSpot AI comes in! We strongly recommend using the StackSpot IA extension in Visual Studio Code to write, suggest improvements, and apply good practices to your BDD, all in an agile and straightforward way.

Installing the StackSpot AI extension

First, you’ll need to install the StackSpot AI extension in your Visual Studio Code. Use this link to install StackSpot AI in your VSCode or search the extensions marketplace.

After installation, the StackSpot AI area will be added to your Visual Studio, where you must log in with your StackSpot account. 

If you don’t have an account, the process is quick: visit the official StackSpot AI website and click on “Try for free”. Use your GitHub account to log in!

That’s it! You’re now inside the StackSpot AI universe!

To learn more about StackSpot AI, read its documentation or watch “Getting Started with StackSpot AI” on the platform after logging in.

Creating a BDD with StackSpot AI

Let’s start by creating a BDD from a software specification (which was also generated by StackSpot IA):

Gherkin
Software History Specification

Title: Search for the term "How to use StackSpot" on mobile using the Google Chrome browser

As an interested user, I want to perform a search for the term "How to use StackSpot" on my cell phone So that I can learn how to use the StackSpot platform through the Google Chrome browser.

Acceptance Criteria:
Browser accessibility:

Given that I have a cell phone with the Google Chrome browser installed,
When I open the browser,
Then, I should be able to access the address bar.
Search performance:

Given that I'm on the Google Chrome homepage,
When I type "How to use StackSpot" into the address bar or Google search bar,
And press the search button or "Enter",
Then, I should see a list of results related to the search term.


Access to Content:

Given that search results are displayed,
When I click on one of the results that seems to provide information on how to use StackSpot,
Then, I should be redirected to the corresponding page,
and be able to read the details on how to use the StackSpot platform.
Usability on Mobile Devices:

Given that I have accessed a page with information on how to use StackSpot,
When I browse the page,
Then, the content should be displayed in a readable way and adapted to my mobile screen,
And I should be able to easily interact with any interactive elements, such as links or buttons.

Visual feedback:

Given that I am interacting with the page,
When I select a link or button,
Then, there should be visual feedback indicating my action, such as a color change or a click effect.

Notes:
The search must be carried out using a stable internet connection to avoid loading problems.
The user should ensure that the Google Chrome browser is up to date for the best possible experience.
This story does not cover specific instructions on installing Google Chrome on mobile devices, assuming the user already has the browser installed and ready to use.

Out of Scope:
Installing the Google Chrome browser on a cell phone.
Troubleshooting internet connection problems.
Specific actions within the StackSpot website after finding the desired information.

For StackSpot AI to understand it as your basis for work, save this specification on a file and keep its contents selected. No other configuration is necessary.

Type in your prompt: “Create a BDD in Gherkin language for the selected story”.

This is the result of the BDD by StackSpot AI technology:

Image of the BDD created by StackSpot AI on the Plugin screen inside Visual Studio Code. 

See the generated BDD:

Gherkin
# language: en
Functionality: Search for the term "How to use StackSpot" on mobile using the Google Chrome browser
  As an interested user
  I want to search for the term "How to use StackSpot" on my cell phone
  So that I can learn how to use the StackSpot platform through the Google Chrome browser
 
 Context:
    Given that I have a cell phone with the Google Chrome browser installed
 
 Scenario: Browser accessibility
    When I open the browser
    Then, I should be able to access the address bar
  
Scenario: Performing the Search
    Given that I'm on the Google Chrome homepage
    When I type "How to use StackSpot" into the address bar or Google search bar
    And press the search button or "Enter."
    Then, I should see a list of results related to the search term.


  Scenario: Access to Content
    Given that search results are displayed
    When I click on one of the results that seems to provide information on how to use StackSpot
    Then, I should be redirected to the corresponding page
    And be able to read the details on how to use the StackSpot platform
 
 Scenario: Usability on Mobile Devices
    Given that I have accessed a page with information on how to use StackSpot
    When I browse the page
    Then, the content should be displayed legibly and adapted to my mobile screen
    And I should be able to interact with any interactive elements, such as links or buttons, without difficulty
  
Scenario: Visual Feedback
    Given that I am interacting with the page
    When I select a link or button
    Then, there should be visual feedback indicating my action, such as a color change or a click effect

Done! StackSpot AI has created a complete BDD based on your functional story. Remember that StackSpot works with the knowledge base provided: the more details, the richer your writing will be!

Improving an existing BDD

Now, if you already have a BDD that requires improvement, StackSpot AI can optimize rewriting and support understanding and learning.

Using an example already written:

Gherkin
#language: en
@Improving_your_bdd_with_StackPot_IA
Feature: Trading via the Mobile Cash app

Context: User with trading permission
Given that I am logged in to the Mobile Cash application
And have permission to renegotiate contracts
And I have contracts to negotiate 
And I click on the menu access 
And click on the negotiation 
And wait for the negotiation area to load

Scenario: CT01 - Access to the negotiation menu 
Then, the application must allow access to the negotiation menu 

Scenario: CT02 - Access to the negotiation menu
When I click on negotiate
Then, the application should redirect to the list of contracts available for trading.

Scenario: CT03 - Access to the settle contracts menu
When I click on settle contracts
Then, the application should be redirected to the contracts available for settlement.

Scenario: CT04 - Access to the Blocked Contracts menu
When I click on blocked contracts
Then, the application should redirect to the list of contracts blocked for renegotiation.

Scenario: CT05 - Validate the negotiation
When I click on negotiate
I access the list of contracts
I choose a contract 
And I click on the choice checkbox
And I click on the Select Contracts button
I check the negotiation conditions
And I choose the conditions I want with a down payment of 1000 reais and the rest in 12 installments.
And click on Negotiate contract. 
Then, the application should show a success screen for the negotiation that is carried out.

*Illustrative data only

Select the BDD content and pass it on to StackSpot AI analysis using the command prompt: “Review and refactor with BDD best practices the selected file”.

This is the result: 

Gherkin
#language: en
@Improving_your_bdd_with_StackPot_IA
Feature: Trading via the Mobile Cash app
  
Context: User with trading permission
    Given that I am logged in to the Mobile Cash application with the username “user_test” and password “password_safe.”
    And have permission to renegotiate contracts
    And have contracts to trade listed in the “Available Contracts” section
    When I access the main menu
    And select the “Negotiation” option
  
Scenario: CT01 - Access to the negotiation menu
    Then, the application should display the negotiation area with the options “Negotiate,” “Settle Contracts,” and “Blocked Contracts.”
 
 Scenario: CT02 - Accessing the negotiate menu
    When I select the “Negotiate” option
    Then, the application should display the list of contracts available for negotiation


  Scenario: CT03 - Access to the Settle Contracts menu
    When I select the “Settle Contracts” option
    Then, the application should display the list of contracts available for settlement
 
 Scenario: CT04 - Access to the Blocked Contracts menu
    When I select the “Blocked contacts” option
    Then, the application should display the list of contracts blocked for renegotiation
  
Scenario: CT05 - Validate the negotiation of a contract
    Given that I am on the list of contracts available for negotiation
    When I select a contract with the ID “12345”.
    And mark the contract for negotiation.
    I select “Select Contracts”.
    And I set the negotiation conditions for a down payment of “1000” reais and the rest in “12” installments.
    And confirm the negotiation.
    Then, the application should display a success message: “Negotiation successfully completed!”

 Scenario: CT06 - Negotiation attempt without contract selection   
 Given that I am on the list of contracts available for trading
    When I try to trade without selecting a contract
    Then, the application should display an error message: “Select a contract to trade.”
  
Scenario: CT07 - Checking for invalid trading conditions
    Given that I am on the trading conditions screen for the contract with ID “67890”
    When I enter an invalid entry of “-500” Reais
    And try to confirm the trade
    Then, the application should display an error message: “Invalid entry. Please enter a positive value.”

Review the content generated by StackSpot AI, understand the tips, and learn more about BDD using our AI tool! 

Consume innovation,
begin transformation

Subscribe to our newsletter to stay updated
on the latest best practices for leveraging
technology to drive business impact

Now learn, refactor, and enjoy! 

With the help of StackSpot AI, you can create and improve the writing of BDDs, facilitating test automation processes. What’s more, it will raise the quality of communication across the entire software engineering team, bringing real benefits and standardizations that can reduce the complexity of the business, which is often very large. 

For more information, tips, and tutorials, check out the official StackSpot AI documentation

Watch a version of this tutorial on our official YouTube channel!

Together, we can transform how we develop, test, and deliver software, making the process more efficient, collaborative, and, above all, more aligned with the needs of the business and end users.

Do you have any questions or suggestions? Leave a comment!

Consume innovation,
begin transformation

Subscribe to our newsletter to stay updated
on the latest best practices for leveraging
technology to drive business impact

Related posts

Download your free eBook and find new ways to evolve your company