This Python script generates test cases for a given requirement specification using OpenAI's GPT-4 model and imports them into XRAY, a test management tool for Jira.
Example run command:
python generate-tcs-for-issue.py --req TST-47 --username [email protected] --url https://test.atlassian.net
The script takes in the following arguments:
--req
: The ID of the Jira issue containing the requirement specification.--username
: The username used to log in to Jira.--url
: The URL of the Jira Cloud instance.--tc_amount
: Amount of Test Cases to generate. Default is 1.--debug
: A boolean flag indicating whether to print debug information.
-
Fetches the requirement data from Jira using the provided issue ID.
-
Generates test cases for the requirement using OpenAI's GPT-4 model.
-
Saves the output to a JSON file.
-
Imports the generated test cases into XRAY using the XRAY API.
See demo video https://www.youtube.com/watch?v=WT9yVStSW48 or in Finnish https://youtu.be/twBfkGKdKg8
requests
: To make HTTP requests to Jira and XRAY.openai
: To interact with OpenAI's GPT-4 API.argparse
: To parse command-line arguments. (build-in Python)json
: To parse json content. (build-in Python)
Install needed libraries by running: pip install -r requirements.txt
Copy and update jira_token.txt from template
eyJhbGciO1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnQiOiIz...........
Copy and update openai.txt from template
sk-0NpOoHLtMASW5ECT3Blb..............
Copy and update xray_auth.json from template
{ "client_id": "FF328C5A1A487E9A...........","client_secret": "bbf3997c59bb1d63e76658fd266414c73............" }