• Skip to main content
Year End Offer: Save 30% + Teams Save Up to an Extra 25%!

EuroSTAR Conference

Europe's Largest Quality Engineering Conference

  • Programme
    • Programme Committee
    • 2025 Programme
    • Community Hub
    • Awards
    • Social Events
    • Volunteer
  • Attend
    • Location
    • Highlights
    • Get Approval
    • Why Attend
    • Bring your Team
    • Testimonials
    • 2025 Photos
  • Sponsor
    • Sponsor Opportunities
    • Sponsor Testimonials
  • About
    • About Us
    • Our Timeline
    • FAQ
    • Blog
    • Organisations
    • Contact Us
  • Book Now

Operationalizing BDD Scenarios Through Generative AI

May 13, 2024 by Lauren Payne

Behavior Driven Development (BDD) is a well-regarded way to write application requirements as scenarios that describe the behaviour in various contexts. BDD evolved from the agile movement and its emphasis on Test-Driven Development (TDD) to take things one step further than simple user stories and document a user’s behaviour when they use a system.

Typically using the Gherkin syntax, a user scenario in BDD is written the following way:

  • Given: the initial context at the beginning of the scenario, in one or more clauses;
  • when: the event that triggers the scenario;
  • then: the expected outcome, in one or more clauses.

Gherkin is a business readable language that helps you to describe business behavior without going into details of implementation. It is a domain-specific language for defining tests in a standardized format for specifications. It uses plain language to describe use cases and allows users to remove logic details from behavior tests. For example:

The primary benefit of BDD is that it encourages communication between developers and other stakeholders, such as product owners and users. BDD helps bridge the gap between technical and non-technical stakeholders by providing a common language for discussing the behavior of the system. By using this language, stakeholders can understand each other’s needs and expectations, leading to better development decisions.

In addition to being a useful way of describing a requirement specification, the text in the Gherkin language acts as both documentation and the skeleton of your automated tests. For example, test automation engineers often take the Gherkin scenarios and use a framework like Cypress or Robot Framework to turn these high-level user interactions into executable test automation scripts. However, this process is manual and can be time consuming, with the automation engineers having to hand-write large amounts of Python or JavaScript to turn one BDD scenario into a functioning automated test.

Enter the Power of Generative AI

With Generative Artificial Intelligence (GenAI), you can use the power of Large Language Models (LLM) to automate a lot of this process. Currently, our SpiraPlan quality and test management system uses GenAI to automatically generate BDD scenarios, test cases, and risks from simple agile user stories:

Figure 1: BDD Gherkin Scenario Generated by AI.

However, this is just the beginning of what will soon be possible!

Using the latest LLMs such as GPT4, we can pass in the BDD scenario text as a prompt to the LLM and it will generate a set of page objects and associated page object models functions/methods. This means that a simple human-readable scenario can automatically turn into a Selenium-style set of page object model function calls.

Figure 2: A Human readable scenario

Figure 3: An automated test script using page objects, automatically generated by AI.

Finally, when you feed either in a specially tagged image of the application or a reduced version of the page DOM (to avoid using too many GenAI tokens), the LLM is able to implement each of the page object model functions into the appropriate code to interact with the application and test its user interface. These could be either image-based clicks or WebDriver-style CSS selectors depending on what you used to prompt the model.

This means we are close to having the holy grail of taking a BDD scenario and automatically converting it into an 80-90% ready-to-run automated testing script.

What is the Role of Testers?

As we often say, GenAI is not here to replace humans, but instead to assist. If we consider this new Human-AI team, the human testers’ job is to create/review scenarios from the AI, review and optimize draft automation code from the AI, and look for weaknesses, edge conditions, and missing cases. Working together, the Human-AI team will be able to reduce higher-quality applications in a faster time than ever thought possible!

Author


Adam Sandman, Director of Technology at Inflectra

Adam Sandman has been a programmer since the age of 10 and has been working in the IT industry for the past 20 years in areas such as architecture, agile development, testing, and project management. Currently, Adam is a Director of Technology at Inflectra, where he is interested in technology, business, and enabling people to follow their passions. At Inflectra, Adam has been responsible for researching the tools, technologies, and processes in the software testing and quality assurance space. Adam has previously spoken at STARWEST, Agile + DevOps West, STPCon, Swiss DevOps Fusion, InflectraCon, TestingMind, EuroSTAR, Agile Testing Days, and STARCANADA.

Inflectra is an Exhibitor at EuroSTAR 2024, join us in Stockholm.

Post Views: 2,008

Filed Under: Software Testing Tagged With: 2024, EuroSTAR Conference, Expo

  • Code of Conduct
  • Privacy Policy
  • T&C
  • Media Partners
  • Contact Us