Created
March 23, 2023 19:24
-
-
Save gpinkham/498ca12621ca7c56bfe84b1b907def9b to your computer and use it in GitHub Desktop.
Retrieve Test Cases from RTM (Jira Plugin) and generate CSV for Importing into Qality Plus (Jira Plugin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def description(desc:) | |
text = '' | |
begin | |
desc["content"]&.each do |c| | |
if c["content"].nil? | |
text << "#{c["text"]}\n" | |
else | |
text << description(desc: c) | |
end | |
end | |
rescue => e | |
puts desc | |
raise e | |
end | |
text | |
end | |
keys = []. # List of Issue IDs | |
url2 = 'rtm-api.hexygen.com' | |
jwt2 = '' # Token generated in the RTM UI | |
http = Net::HTTP.new(url2, 443) | |
http.use_ssl = true | |
CSV.open("export-rtm.csv", "wb") do |csv| | |
headers = ['key', 'summary', 'desc', 'assignee', 'action', 'input', 'expected'] | |
csv << headers | |
keys.each do |key| | |
request = Net::HTTP::Get.new("/api/v2/test-case/#{key}") | |
request['Authorization'] = "BEARER #{jwt2}" | |
response = http.request(request) | |
data = JSON.parse(response.body) | |
key = data['testKey'] | |
summary = data["summary"] | |
desc = data["description"].nil? ? '' : description(desc: JSON.parse(data["description"])) | |
assignee = data["assigneeId"] | |
stepGroups = data['stepGroups'] | |
if stepGroups.nil? | |
csv << [key, summary, desc, assignee, '', '', '' ] | |
else | |
had_any_steps = false | |
stepGroups.each do |sg| | |
sg["steps"]&.each do |s| | |
action = '' | |
input = '' | |
expected = '' | |
s['stepColumns'].each do |sc| | |
action = sc['value'] if sc['name'] == "Action" | |
input = sc['value'] if sc['name'] == "Input" | |
expected = sc['value'] if sc['name'] == "Expected result" | |
end | |
csv << [key, summary, (had_any_steps ? '' : desc), assignee, action, input, expected] | |
had_any_steps = true | |
end | |
end | |
unless had_any_steps | |
csv << [key, summary, desc, assignee, '', '', '' ] | |
end | |
end | |
sleep(1). # sleeping to avoid rate limiting by RTM | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't format the Description. so that would be a future enhancement. Also possibly grabbing the PreConditions from RTM and adding to the Description. PreConditions are not supported in Qality