visit
In the past 2 years, the advancement in AI, especially LLMs (Large Language Models), has turned out to solve traditional problems more efficiently, and one such impact that LLMs can create is through assistance in automating our software testing. For many software teams automation has never been a first-class citizen of the SDLC cycle and teams struggle to automate the test cases that create the "Test Automation Debt". Due to this gap in test automation, a lot of time for quality teams go into manually verifying and writing these test cases which as a result slows down the engineering team's shipping velocity.
Although all the problem mentioned above needs a separate article on how software teams should tackle them, in this section we will talk about how QA engineers can leverage the ChatGPT or LLMs as their co-pilot in BDD (behavior-driven testing)
What is BDD?
Behavior-driven development (BDD) is an Agile software development methodology in which an application is documented and designed around the behavior a user expects to experience when interacting with it. For the context of this discussion let's apply BDD-based testing on a YC website and consider the login page of YC hacker news as a starting point.
"When a user attempts to log in and enters the valid credentials on and presses login it should redirect the user to hacker news website".
As per BDD guidelines, the above behavior can be written as Gherkin syntax/steps which can be a possible test case, and using cucumber as a framework the same Gherkin can be automated and this behavior would no further need human intervention. However, due to the problem we discussed in the section above QA team generally suffers in automating the same, but we can leverage the power of LLMs by writing a few prompts and creating a workflow for our QA teams to churn the Gherkin steps and its automation with faster velocity on cucumber framework.
Workflow for Generating Gherkin Syntax
Workflow for generating cucumber-compatible code from Gherkin Syntax
Step 1: Prompt to be engineered
Step 2: Injecting the relevant HTML which needs to be used as a base for automation.
As depicted below after fine-tuning the ChatGPT asks for the relevant HTML and Gherkin steps which it can use to generate step definitions for cucumber.
Step3: Generating the step definition
Feature: User Login Redirect
Scenario: User logs in with valid credentials
Given the user is on the login page of "//news.ycombinator.com/login?goto=news"
When the user enters valid credentials and presses the login button
Then the user should be redirected to the "hacker news" website
Final output