1

我正在做一个工具来从 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=>[“无法解析:无法解析表达式“版本测试”作为查询”]

非常感谢。

4

1 回答 1

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
于 2013-06-20T15:27:03.550 回答