1

我有一个SOAP UI 4.5.1,我进行了负载测试,它工作正常。我的问题是我每次都运行相同的请求,我需要更改我发送的肥皂请求的值。

例如,我有一个我的肥皂请求块:

 <ns:Assessment>
    <ns:Project>
       <ns:ProviderId>SHL</ns:ProviderId>
       <ns:ProjectId>SampleAssessment</ns:ProjectId>
    </ns:Project>
 </ns:Assessment>

提供者 ID:SHL 项目 ID:SampleAssessment

有没有办法让这些值从某种间隔发生变化?例如:提供商 ID[SHL, SLH, LHS] 项目 ID[SampleAssessment, TestAssessment, AnotherAssessment]

通过负载测试,我发出了三个请求,因此第一个请求值如下所示:

 <ns:Assessment>
    <ns:Project>
       <ns:ProviderId>SHL</ns:ProviderId>
       <ns:ProjectId>SampleAssessment</ns:ProjectId>
    </ns:Project>
 </ns:Assessment>

对于第二个这样的:

 <ns:Assessment>
    <ns:Project>
       <ns:ProviderId>SLH</ns:ProviderId>
       <ns:ProjectId>TestAssessment</ns:ProjectId>
    </ns:Project>
 </ns:Assessment>

等等...

有没有办法通过 SOAP UI 实现这一点?

4

2 回答 2

2

From my experience, you will need to use a Groovy Script step.

For example, if you have a step before your request that is a script, you can use something like:

context.setProperty("ProviderId", "SHL")

Then in your request, use:

<ns:ProviderId>${ProviderId}</ns:ProviderId>

Of course, this doesn't buy you much by itself. There are few ways to vary what the context.setProperty("ProviderId", "SHL") line will set. You can create a collection and iterate over it using something like:

 def providers = ['ABC', 'DEF', 'GHI', 'JKL']

 providers.each() {
     context.setProperty("ProviderId", it)
     testRunner.runTestStepByName( "nameofteststep" )
 }

Where "nameofteststep" is the name of the Soap Request test step. This might sound odd, but if you right click the test step and disable it, the groovy script will still be able to execute it but it will not run sequentially. By that I mean that the groovy script will run it 4 times, but it won't run a fifth time when the script is complete because it is after the script. Then you just need to keep in mind that each load test thread makes four requests, but I am pretty sure that the SoapUI statistics will take this into account for you... might want to keep an eye out for it, though.

Alternatively, you could check the 'threadIndex' and set a the context variable based on that. A bit like this here: Log ThreadCount.

You could also use a collection without a loop and increment an index that you save as a testcase property and send the string corresponding to the index.

Personally, I think the first way is the most straightforward but I can provide an example of the other ones if you like.

于 2012-10-24T16:25:07.587 回答
1

有一种简单的方法可以做到这一点,而无需编写 groovy 脚本。

创建测试用例后,您应该包括以下测试步骤:

1-数据源

2-请求

三环

数据源将读取一个 excel 文件(或其他数据源方法,如 XML、groovy、JDBC、gird .. 但是 excel 是最简单的一种)。您应该包含数据(您需要在请求中更改)

在测试请求中,您需要右键单击并选择“获取数据”。请注意,您的测试请求应如下所示

<ns:ProviderId>${ProviderId}</ns:ProviderId>

然后最后一步是“循环”。这用于返回第一步,直到数据结束。

我希望这有帮助。

于 2012-10-30T13:16:17.113 回答