SoapUI:测试用例中的属性扩展中未使用的属性
我使用的是soapUI 3.6.1,我想使用如下测试结构来测试SOAP 接口:
MyWorkspace
MyProject
TestSuite
TestCase Single
TestStep 1
TestCase Loop
Properties #1
Groovy #1
Run TestCase Single
Properties #2
Groovy #2
Run TestCase Single
TestCase Single
包含一堆应使用相同帐户ID 执行的请求。 TestCase Loop
应该使用不同的帐户 ID 调用 TestCase Single
。 Properties *
应该更改帐户 ID。
MyProject
有一个属性 accountId
设置为值 1234。这应该作为测试用例单一测试的默认值,即 TestCase Single
。
Properties #1
和 Properties #2
使用不同的值指定了 accountId
。
目的是允许 TestStep 1
单独执行或作为 TestCase Loop
的一部分执行。
TestStep 1
有一个通用的 SOAP 主体,其中以下是发送到 Web 服务的参数:
<accId>${='${#accountId}' != '' ? '${#accountId}' : ${#Project#accountId}}</accId>
Groovy #1
和 Groovy #2
外观像这样:
log.info('Using account ' + (context.expand('${#accountId}') != '' ? context.expand('${#accountId}') : context.expand('${#Project#accountId}')));
我现在的问题是 Groovy 脚本写入了正确的 accountId 值(即循环内的值),但 TestStep 1 始终使用该值从项目中。我希望 TestStep 1
使用循环的值。
出于调试目的,我还将以下内容放入 TestStep 1
中:
<!--
{#Project#accountId}: ${#Project#accountId}
{#TestSuite#accountId}: ${#TestSuite#accountId}
{#TestRunContext#accountId}: ${#TestRunContext#accountId}
{#TestRun#accountId}: ${#TestRun#accountId}
{#TestCase#accountId}: ${#TestCase#accountId}
{#TestStep#accountId}: ${#TestStep#accountId}
{#MockService#accountId}: ${#MockService#accountId}
{#Global#accountId}: ${#Global#accountId}
{#System#accountId}: ${#System#accountId}
{#Env#accountId}: ${#Env#accountId}
{#accountId}: ${#accountId}
context.accountId: ${=context.accountId}
modelItem.accountId: ${=modelItem.accountId}
request.accountId: ${=request.accountId}
context.expand(): ${=context.expand('${#accountId}')}
-->
我使用 Wireshark 跟踪网络流量,并注意到只有 ${#Project#accountId}
返回了值。
我在这里做错了什么?我需要如何对
元素进行编码才能将正确的值发送到远程主机?
I'm using soapUI 3.6.1 and I want to test a SOAP-interface with a test structure like this:
MyWorkspace
MyProject
TestSuite
TestCase Single
TestStep 1
TestCase Loop
Properties #1
Groovy #1
Run TestCase Single
Properties #2
Groovy #2
Run TestCase Single
TestCase Single
contains a bunch of requests that should be performed with the same account-id. TestCase Loop
is supposed to call TestCase Single
using different account-ids. The Properties *
are supposed to change the account-id.
MyProject
has a property accountId
set up with value 1234. This should work as the default value for single testing of the test cases, i.e. TestCase Single
.
Properties #1
and Properties #2
have accountId
specified with different values.
The intention is to allow TestStep 1
to be executed alone or as part of TestCase Loop
.
TestStep 1
has a common SOAP-body where the following is a parameter sent to the web-service:
<accId>${='${#accountId}' != '' ? '${#accountId}' : ${#Project#accountId}}</accId>
Groovy #1
and Groovy #2
look like this:
log.info('Using account ' + (context.expand('${#accountId}') != '' ? context.expand('${#accountId}') : context.expand('${#Project#accountId}')));
My problem now is that the Groovy-script writes the correct value of accountId
(i.e., the one inside the loop), but the TestStep 1
always uses the value from the project. I want TestStep 1
to use the value of the loop.
For debugging purposes I also put the following into TestStep 1
:
<!--
{#Project#accountId}: ${#Project#accountId}
{#TestSuite#accountId}: ${#TestSuite#accountId}
{#TestRunContext#accountId}: ${#TestRunContext#accountId}
{#TestRun#accountId}: ${#TestRun#accountId}
{#TestCase#accountId}: ${#TestCase#accountId}
{#TestStep#accountId}: ${#TestStep#accountId}
{#MockService#accountId}: ${#MockService#accountId}
{#Global#accountId}: ${#Global#accountId}
{#System#accountId}: ${#System#accountId}
{#Env#accountId}: ${#Env#accountId}
{#accountId}: ${#accountId}
context.accountId: ${=context.accountId}
modelItem.accountId: ${=modelItem.accountId}
request.accountId: ${=request.accountId}
context.expand(): ${=context.expand('${#accountId}')}
-->
I traced the network traffic with Wireshark and noticed that only ${#Project#accountId}
returned a value.
What am I doing wrong here? How do I need to code the <accId>
-element to send the correct value to the remote host?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在我重新审视这个问题,我认为我找到了最好的解决方案,尽管我不明白为什么我最初的尝试不起作用。
我将结构更改为:
换句话说,我摆脱了
Properties
并将逻辑移至Groovies
:以及
TestStep 1
中的相应行代码>:Now I revisited this issue and I think I found the best possible solution, even though I don't understand why my initial attempt didn't work.
I changed the structure to this:
In other words I got rid of the
Properties
and moved the logic into theGroovies
:and the appropriate line in
TestStep 1
: