SoapUI:测试用例中的属性扩展中未使用的属性

发布于 2024-10-11 18:25:21 字数 2307 浏览 3 评论 0原文

我使用的是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 SingleProperties * 应该更改帐户 ID。

MyProject 有一个属性 accountId 设置为值 1234。这应该作为测试用例单一测试的默认值,即 TestCase Single

Properties #1Properties #2 使用不同的值指定了 accountId

目的是允许 TestStep 1 单独执行或作为 TestCase Loop 的一部分执行。

TestStep 1 有一个通用的 SOAP 主体,其中以下是发送到 Web 服务的参数:

     <accId>${='${#accountId}' != '' ? '${#accountId}' : ${#Project#accountId}}</accId>

Groovy #1Groovy #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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见你 2024-10-18 18:25:21

现在我重新审视这个问题,我认为我找到了最好的解决方案,尽管我不明白为什么我最初的尝试不起作用。

我将结构更改为:

MyWorkspace
    MyProject
        TestSuite
            TestCase Single
                TestStep 1
            TestCase Loop
                Groovy #1
                Run TestCase Single
                Groovy #2
                Run TestCase Single

换句话说,我摆脱了 Properties 并将逻辑移至 Groovies

context.getTestCase().getTestSuite().setPropertyValue("accountId_loop", "1720");

以及 TestStep 1 中的相应行代码>:

     <accId>${='${#TestSuite#accountId_loop}' != '' ? '${#TestSuite#accountId_loop}' : ${#MyProject#accountId}}</accId>

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:

MyWorkspace
    MyProject
        TestSuite
            TestCase Single
                TestStep 1
            TestCase Loop
                Groovy #1
                Run TestCase Single
                Groovy #2
                Run TestCase Single

In other words I got rid of the Properties and moved the logic into the Groovies:

context.getTestCase().getTestSuite().setPropertyValue("accountId_loop", "1720");

and the appropriate line in TestStep 1:

     <accId>${='${#TestSuite#accountId_loop}' != '' ? '${#TestSuite#accountId_loop}' : ${#MyProject#accountId}}</accId>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文