Gen-AI for QA: Auto-Generating Cucumber BDD Scenarios from JIRA Stories Using AI
These days, software is being released so quick and deadlines are getting shorter, QA teams receive continued demands to achieve higher testing speed with fewer bugs while maintaining top-level quality standards. But we know that writing test cases manually takes a lot of time, effort, its repetitive and also sometimes we may miss some important scenarios through the cracks.
That’s where Generative AI steps in, It's a game changer that helps teams to instantly generate smart, detailed test cases(cucumber scenarios) for JIRA USER STORIES and stores them directly in Cucumber BDD Maven Project.
What You’ll Build
A Python-based Program that:
Connects to your JIRA project using the JIRA API
User stories are fetched automatically
Gherkin format test cases are created using Gen AI like GPT-4
Covers functional, negative, boundary, security, and performance scenarios
Saves scenarios directly into cucumber BDD maven project
Let’s dive in:
STEP 1: Setup JIRA API Access:
1.1 Create an API Token in JIRA:
Log in to your JIRA Cloud account
Go to Account Settings > Security > API Tokens
Click on Create API Token and save the API token
(NOTE: save API token. Same token can't be retrieved again)
Validate your API token by running a curl command
Convert your API token to base64 using below command/First encode your credentials
COMMAND: echo -n "YOUR EMAIL:YOUR_API_TOKEN"|base64
Now, use that encoded string in curl (This will display list of projects in your jira account)
USE BELOW COMMAND:
curl -X GET -H "Accept: application/json" -H "Authorization: Basic YOUR_base64code=” "YOUR_JIRA_DOMAIN/rest/api/3/search?jql=project=YOUR_PROJECT_KEY"
(NOTE: The above curl command is used to verify that the API is working properly-
If you see list of projects in the result -consider it as working fine )
1.2 Create User Stories in Jira:
Create user stories in your jira project
NOTE: A User Story should be written as a story and placed in the To Do section.
EXAMPLE: User should be able to reset password
STEP 2: Store JIRA API Credentials
Create a file with .env extension in your local
Store the JIRA domain, email, and API token securely
EXAMPLE: credentials.env

STEP 3: Get the User Stories from JIRA
Install Python, add the installation path to the Environment Variables (Path), and verify that the installation is successful.
3.1 Install Required Libraries using below command:
Open Terminal
COMMAND: pip install requests openai python-dotenv
3.2 Use Python to fetch JIRA issues (User Stories) via API.
Save this code file(save with filename.py) in your local directory
Example: story.py
NOTE: .env file and .py file should be in the same directory
Python function to fetch jira stories:
Open Terminal and Run your code using below command:
Py filename.py
Example Output: User should be able to reset password
NOTE: This code fetches the user stories from jira
Video Guide:
STEP 4: Test Case generation using Gen-AI for the User Stories
We generate test cases using OpenAI's GPT4 now
Visit https://platform.openai.com/signup/ Sign up or log in with your OpenAI account.
Next Generate API Key:
Select "View API Keys" or directly go to:
Click on "Create a new secret key".
Note: Make sure to copy the key securely and store it.
ADD that to OPEN_AI API key in the .env file (paste it in the same above .env file)

Generate Test Cases using updated Python Function:
Example Test Case Output (Gherkin Format):
Example story: "User can reset the password"
The AI might generate below test cases in GHERKIN format

Video Guide:
STEP 5: Storing the generated test cases in the Cucumber BDD Maven project
Create a Cucumber BDD Maven Project
Create a package named features under src/test/resources.
Be sure to replace the project path in the code with your own.
Modified Python Function to Generate Test Cases:
Run the program, and after generating the test cases successfully, go to the Maven project and refresh it. You will see the generated feature files with scenarios under the features package located in the src/test/resources folder.
Video Guide:
Challenges to Watch Out :
Make sure to review the test cases generated by AI before using them in the projects.
Not all the required edge cases will be covered - you may still need to add a few tests by yourself
Update your prompts regularly based on you app updates to keep the test cases accurate
Future Enhancements:
Connect the test cases with tools like Zephyr so you can manage everything directly in JIRA.
You can also add Python code to this code which automatically generate code for given scenarios
In each sprint we can track the no of test cases created by creating a dashboard
Conclusion
Using Generative AI with JIRA makes the testing process quicker and simpler. It removes manual effort by automatically generating test cases and helps in detecting bugs earlier, and also maintains high quality product.
When the repetitive tasks are completed by AI, QA teams can focus on other tasks like improving the user experience, focusing on new features and identifying risks.
AI-driven testing is not only for just speeding the tasks - its about creating the reliable products in a smarter way.
The future of testing is here—and it’s intelligent, efficient, and AI-driven.
Happy Learning!!!!



