开发者

How? SOAPUI and Groovy - send different SOAP message (with property from file) each time?

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 pop开发者_开发百科ulate 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜