如何在测试步骤中使用(本地)变量/参数

时间:2013-11-28 09:22:31

标签: soapui

我有一个包含此XML的测试步骤:

<mes:ItemIds>
  <typ:OccurrenceItemId RecurringMasterId="AQMkADkyZTQxNjUzLTcwZTQtNGRlNS04M2VmLWMxYmIBNWJiADUwZTYARgAAA4Kt4mOTlXZJrZx0v5cQm8IHAISmF1hx/2pAhQBTVUBmYgoAAAMhAAAAhKYXWHH/akCFAFNVQGZiCgACKdAKmwAAAA==" InstanceIndex="1"/>
  <typ:OccurrenceItemId RecurringMasterId="AQMkADkyZTQxNjUzLTcwZTQtNGRlNS04M2VmLWMxYmIBNWJiADUwZTYARgAAA4Kt4mOTlXZJrZx0v5cQm8IHAISmF1hx/2pAhQBTVUBmYgoAAAMhAAAAhKYXWHH/akCFAFNVQGZiCgACKdAKmwAAAA==" InstanceIndex="2"/>
  <typ:OccurrenceItemId RecurringMasterId="AQMkADkyZTQxNjUzLTcwZTQtNGRlNS04M2VmLWMxYmIBNWJiADUwZTYARgAAA4Kt4mOTlXZJrZx0v5cQm8IHAISmF1hx/2pAhQBTVUBmYgoAAAMhAAAAhKYXWHH/akCFAFNVQGZiCgACKdAKmwAAAA==" InstanceIndex="3"/>
  <typ:OccurrenceItemId RecurringMasterId="AQMkADkyZTQxNjUzLTcwZTQtNGRlNS04M2VmLWMxYmIBNWJiADUwZTYARgAAA4Kt4mOTlXZJrZx0v5cQm8IHAISmF1hx/2pAhQBTVUBmYgoAAAMhAAAAhKYXWHH/akCFAFNVQGZiCgACKdAKmwAAAA==" InstanceIndex="4"/>
  <typ:OccurrenceItemId RecurringMasterId="AQMkADkyZTQxNjUzLTcwZTQtNGRlNS04M2VmLWMxYmIBNWJiADUwZTYARgAAA4Kt4mOTlXZJrZx0v5cQm8IHAISmF1hx/2pAhQBTVUBmYgoAAAMhAAAAhKYXWHH/akCFAFNVQGZiCgACKdAKmwAAAA==" InstanceIndex="5"/>
  <typ:OccurrenceItemId RecurringMasterId="AQMkADkyZTQxNjUzLTcwZTQtNGRlNS04M2VmLWMxYmIBNWJiADUwZTYARgAAA4Kt4mOTlXZJrZx0v5cQm8IHAISmF1hx/2pAhQBTVUBmYgoAAAMhAAAAhKYXWHH/akCFAFNVQGZiCgACKdAKmwAAAA==" InstanceIndex="6"/>
...

我在免费版本的SOAPUI中手动执行此操作。

当我需要使用不同的RecurringMasterId进行测试时,可以进行全局替换,但我宁愿做类似的事情

somevariable="AQMkADkyZTQxNjUzLTcwZTQtNGRlNS04M2VmLWMxYmIBNWJiADUwZTYARgAAA4Kt4mOTlXZJrZx0v5cQm8IHAISmF1hx/2pAhQBTVUBmYgoAAAMhAAAAhKYXWHH/akCFAFNVQGZiCgACKdAKmwAAAA=="
<mes:ItemIds>
  <typ:OccurrenceItemId RecurringMasterId=somevariable InstanceIndex="1"/>
  <typ:OccurrenceItemId RecurringMasterId=somevariable InstanceIndex="2"/>
  <typ:OccurrenceItemId RecurringMasterId=somevariable InstanceIndex="3"/>
  <typ:OccurrenceItemId RecurringMasterId=somevariable InstanceIndex="4"/>
  <typ:OccurrenceItemId RecurringMasterId=somevariable InstanceIndex="5"/>
  <typ:OccurrenceItemId RecurringMasterId=somevariable InstanceIndex="6"/>

我该怎么做?

1 个答案:

答案 0 :(得分:0)

我会在测试用例中添加自定义属性,然后在请求之前添加Groovy Script步骤。在脚本中设置您的属性(somevariable),如此处所述[{3}},并通过这种方式访问​​请求中的属性<typ:OccurrenceItemId RecurringMasterId=${#TestCase#somevariable} InstanceIndex="1"/>