如何? SOAPUI 和 Groovy - 每次发送不同的 SOAP 消息(带有文件中的属性)?
我正在尝试使用 SOAPUI (4.0) 进行负载测试,并且希望每个 SOAP 请求都不同,请求中的某些属性值和元素值是从(例如)文本文件填充的。
除了几个属性值和元素值之外,每个请求的 SOAP 消息都是相同的。
SOAP 消息包含未签名的 SAML 断言,并且该断言的一些属性对于每个 SOAP 请求来说可能都不同。在这些属性中,有一个称为“IssueInstant”,它基本上是一个日期/时间戳字符串,还有一个“Id”属性,它是每个请求的唯一字符串。
理想情况下,我希望能够从文本文件填充“Id”属性值。
我已经能够在 SOAPUI 中自动填充 IssueInstant,通过包含一小段 Groovy 代码来获取当前日期/时间,重新格式化它,然后将其存储在属性中。此 Groovy 代码位于 SOAPUI 测试用例的启动脚本中。
在 SOAP 消息的正文中,我有一个要从文本文件填充的主题元素。
填充 IssueInstant、Id 和主题后,我希望 SOAPUI 发送请求。
因此,举例来说,假设文本文件具有:
id0001,cn=foo1,dc=whatever,dc=com
id0002,cn=foo2,dc=whatever,dc=com
id0003,cn=foo3,dc=whatever,dc=com
然后,当我运行 SOAPUI 负载测试时,我希望第一个请求具有 Id=id0001
和主题 cn=foo1,dc =whatever,dc=com
,第二个请求有 Id=id0002
和主题 cn=foo2,dc=whatever,dc=com
,第三个请求要求有Id=id0003
和主题 cn=foo3,dc=whatever,dc=com
,然后负载测试循环返回这 3 组值,直到结束。
我很难理解的是如何在 Groovy 代码中单步执行文件,以及 Groovy 代码如何知道文本文件中的哪一行是构建属性的下一行?
我希望这个对我正在寻找的内容的解释足够清楚。如果没有,请告诉我,我希望有人能提供帮助。
I'm trying to use SOAPUI (4.0) to do load testing, and I want to have each SOAP request be different, with some attribute values and element values in the requests being populated from (for example) a text file.
The SOAP message is going to be the same for each request, except for the several attribute values and element values.
The SOAP message includes an unsigned SAML assertion, and that has some attributes that need potentially be different for each SOAP request. Among these attributes there's one called "IssueInstant" which is basically a date/timestamp string, and an "Id" attribute, which is a unique string per request.
Ideally, I'd like to be able to populate that "Id" attribute value from the text file.
I've been able to populate the IssueInstant automatically in SOAPUI, by including a small piece of Groovy code, to get the current date/time, re-format it, then store that in a property. This Groovy code is in the startup script in the SOAPUI testcase.
In the body of the SOAP message, I have a Subject element that I want to have populated from the text file.
After the IssueInstant, Id, and Subject are populated, I want SOAPUI to send the request.
So, for example, say the text file has:
id0001,cn=foo1,dc=whatever,dc=com
id0002,cn=foo2,dc=whatever,dc=com
id0003,cn=foo3,dc=whatever,dc=com
Then, when I run the SOAPUI load test, I'd like the first request to have Id=id0001
and subject cn=foo1,dc=whatever,dc=com
, the second request to have Id=id0002
and subject cn=foo2,dc=whatever,dc=com
, and the third request to have Id=id0003
and subject cn=foo3,dc=whatever,dc=com
, and then the load test loops back through those 3 sets of values until it ends.
The thing that I'm having a hard time understanding is how to step through the file in the Groovy code and how the Groovy code is suppose to know which line in the text file is the next line from which to build the properties?
I hope that this explanation of what I'm looking for is clear enough. If not, please let me know, and I hope that someone can help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在soapUI Pro中存在所谓的
DataSource
和DataSource Loop
测试步骤。它们用于循环一组测试数据。例如文本文件。如果您有能力使用soapUI Pro,我建议您看一下:http://soapui.org/Data-Driven-Testing/function-tests.html否则,您必须通过 groovy 加载文件。
我相信您会通过 Google 找到一些代码片段。
创建一个初始值为 1 的测试用例属性。读取一行后始终将值增加 1。通过读取此属性在你的常规代码中,你总是知道该读哪一行。
In soapUI Pro there exist so called
DataSource
andDataSource Loop
test steps. They are used for looping through a set of test data. For example a text file. If you have the ability to use soapUI Pro, I recommend you to have a look at this: http://soapui.org/Data-Driven-Testing/functional-tests.htmlOtherwise you have to load the file via groovy.
I'm sure you'll find some code snippets via Google.
Create a test case property with initial value 1. Always after reading a line increment the value by 1. By reading this property in your groovy code you always know which line to read.