我在Rally中收集了大量测试用例。为了更容易搜索测试用例,我在测试用例对象中引入了一个新字段,称为“功能”。此字段的属性类型为“下拉列表(多值)”。现在我需要创建一个Ruby脚本,这样我就可以给这个字段分配(可能有多个)值,这就是我的问题所在:我该如何编写它?我假设变量包含一个数组或指向列表的指针。我希望能够分配和删除单个值,而不影响已经分配给特定测试用例的其他值。
通过查看当我查询变量时Rally返回的内容,我真的不知道它是如何结构的。
"https://rally1.rallydev.com/slm/webservice/v2.0/attributedefinition/68878414616", "_refObjectUUID": "8cb97bae-ea25-4805-8e5b-77944ddc4f6a", "_refObjectName": "Functionality", "_type": "AttributeDefinition"}, "StringValue": "Account History", "ValueIndex": 0, "_type": "AllowedAttributeValue"}, {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "_ref":
我已经浏览了例子和拉力赛应用编程接口,但是没有找到任何关于如何做到这一点的信息。
更新:
根据@JPKole的代码片段,我创建了一个程序。
fields = {:attributedefinition => { '_ref' => this_artifact._ref },
:stringvalue => string_value
}
puts fields
puts "Allowed Attribute Value is #{:allowedattributevalue}"
new_value = @rally.create(:allowedattributevalue, fields)
我认为程序会将正确的值加载到字符串_值和字段变量中。puts行给出:处理测试用例TC7203
{:属性定义=
其中71703906048是我正在处理的测试用例的ID。但我得到了以下信息:
由于错误,测试用例TC7203未更新
请求时出错-https://rally1.rallydev.com/slm/webservice/v2.0/allowedattributevalue/create?workspace=workspace/50775741420-{:错误=
知道我做错了什么吗?
“value_strings”是一个新值数组;“当前允许的值”是现有值的数组:
....
value_strings.each do |string_value|
string_value.strip!
if current_allowed_values.include?(string_value)
puts "Skipping #{string_value} (already exists)"
else
puts " Adding value: #{string_value}"
fields = {:attributedefinition => { '_ref' => attribute._ref },
:stringvalue => string_value
}
new_value = @rally.create(:allowedattributevalue, fields)
end
end