如何? SOAPUI 和 Groovy - 每次发送不同的 SOAP 消息(带有文件中的属性)?

发布于 2024-11-19 21:18:43 字数 1055 浏览 5 评论 0原文

我正在尝试使用 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 技术交流群。

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

发布评论

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

评论(1

天煞孤星 2024-11-26 21:18:43

在soapUI Pro中存在所谓的DataSourceDataSource Loop测试步骤。它们用于循环一组测试数据。例如文本文件。如果您有能力使用soapUI Pro,我建议您看一下:http://soapui.org/Data-Driven-Testing/function-tests.html

否则,您必须通过 groovy 加载文件。

如何在 Groovy 代码中单步执行文件

我相信您会通过 Google 找到一些代码片段。

Groovy 代码如何知道文本文件中的哪一行是构建属性的下一行

创建一个初始值为 1 的测试用例属性。读取一行后始终将值增加 1。通过读取此属性在你的常规代码中,你总是知道该读哪一行。

In soapUI Pro there exist so called DataSource and DataSource 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.html

Otherwise you have to load the file via groovy.

how to step through the file in the Groovy code

I'm sure you'll find some code snippets via Google.

how the Groovy code is suppose to know which line in the text file is the next line from which to build the properties

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文