我正在使用Jenkins作业为我提供的xml文件自动创建测试文件夹(测试套件)和测试用例的工具。 可能是一个愚蠢的事情,但我找不到解决方案,事情是当测试文件夹名称包含一个空格时,我无法查询它是否已经存在。我试图逃脱空白并将其编码为url但没有任何反应。
test_suite_name = ts_line["name"]
if test_suite_name.match(/\s/)
#test_suite_name_nows = test_suite_name.gsub(/ /,"\\ \\")
test_suite_name_nows = URI::encode(test_suite_name)
end
#==================== Querying the test suite in Rally ==========================
test_suite_query = RallyAPI::RallyQuery.new({:type => :testfolder, :query_string => "(Name = #{test_suite_name_nows})"})
您知道哪个格式能够将测试文件夹名称查询为“Test folder1”??
我总是得到:
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/rally_api-0.9.14/lib/rally_api/rally_json_connection.rb:153:in`send_request':( StandardError) 请求错误 - https://rally1.rallydev.com/slm/webservice/1.42/testfolder.js - {:errors => [“无法解析:无法解析表达式\”版本测试\“作为查询”]
非常感谢。
答案 0 :(得分:0)
格式如下:
query.query_string = "(Name = \"My Test Folder 1\")"
和一个完整的例子:
require 'rally_api'
#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "find test folder"
headers.vendor = "NickM RallyLab"
headers.version = "1.0"
# Connection to Rally
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "user@co.com"
config[:password] = "1984"
config[:workspace] = "W"
config[:project] = "P"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()
@rally = RallyAPI::RallyRestJson.new(config)
query = RallyAPI::RallyQuery.new()
query.type = :test_folder
query.fetch = "Name,FormattedID"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.43/workspace/12345.js" } #use yoru OID
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.43/project/67890.js" } #user yoru OID
query.page_size = 200 #optional - default is 200
query.limit = 1000 #optional - default is 99999
query.project_scope_up = false
query.project_scope_down = true
query.order = "Name Asc"
query.query_string = "(Name = \"My Test Folder 1\")"
results = @rally.find(query)
results.each do |t|
puts "Name: #{t["Name"]}, FormattedID: #{t["FormattedID"]}"
t.read
#.............
end