我查询了测试文件夹并获得了查询结果。现在我需要通过测试文件夹找到测试用例。我应该通过引用还是任何其他属性进行查询?我想知道我需要使用的语法。
问问题
742 次
1 回答
1
假设您有测试文件夹名称作为先前查询的结果:
folder_name = tf_results.first.Name
可以使用以下语法找到与此测试文件夹关联的测试用例:
tc_query.query_string = "(TestFolder.Name = \"#{folder_name}\")"
这是使用Rally Ruby REST API (rally_api gem) 的完整代码。
require 'rally_api'
#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "find test cases by test folder name"
headers.vendor = "Nick M RallyLab"
headers.version = "1.0"
# Connection to Rally
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "user@co.com"
config[:password] = "secret"
config[:workspace] = "W"
config[:project] = "P"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()
@rally = RallyAPI::RallyRestJson.new(config)
tf_query = RallyAPI::RallyQuery.new()
tf_query.type = :testfolder
tf_query.fetch = "Name,FormattedID"
tf_query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.43/workspace/11111.js" } #optional
tf_query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.43/project/22222.js" } #optional
tf_query.page_size = 200 #optional - default is 200
tf_query.limit = 1000 #optional - default is 99999
tf_query.project_scope_up = false
tf_query.project_scope_down = true
tf_query.order = "Name Asc"
tf_query.query_string = "(Name = \"My Test Folder 1\")"
tf_results = @rally.find(tf_query)
tf_results.each do |t|
puts "Name: #{t["Name"]}, FormattedID: #{t["FormattedID"]}"
t.read
end
folder_name = tf_results.first.Name
tc_query = RallyAPI::RallyQuery.new()
tc_query.type = :testcase
tc_query.fetch = "Name,FormattedID"
tc_query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.43/workspace/12352608129.js" } #optional
tc_query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.43/project/12352608219.js" } #optional
tc_query.page_size = 200 #optional - default is 200
tc_query.limit = 1000 #optional - default is 99999
tc_query.project_scope_up = false
tc_query.project_scope_down = true
tc_query.order = "Name Asc"
tc_query.query_string = "(TestFolder.Name = \"#{folder_name}\")"
puts "same string" if ("My Test Folder 1" == folder_name)
tc_results = @rally.find(tc_query)
tc_results.each do |t|
puts "Name: #{t["Name"]}, FormattedID: #{t["FormattedID"]}"
t.read
end
于 2013-08-19T14:57:34.967 回答