Jmeter-生成xml

发布于 2024-08-20 18:45:48 字数 259 浏览 1 评论 0原文

我有一个 J2EE 应用程序需要一些广泛的集成测试。我正在使用 Jmeter 生成 HTTP POST 请求。到目前为止,我设法将它们正确发送到服务器,但 xml 是静态的。
我正在寻找一种将动态/随机值插入到 XML 中然后将其发送到服务器的方法。像预处理器之类的东西,但我不确定它是如何完成的。

谁能提供:
1.JMeter教程?
2. 如何生成动态/随机的xml内容到HTTP请求
3. JMeter 示例

非常感谢,
加迪。

I have a J2EE application that needs some extensive integration testing. I am using Jmeter to generate HTTP POST requests. So far I manage to send them to the server correctly but the xml is static.
I am looking for a way to insert dynamic/random values into the XML and then send it to the server. Something like a PreProcessor but I am not sure how it is done.

Can anyone provide:
1. JMeter tutorials?
2. How to generate dynamic/random xml content to HTTP request
3. JMeter examples

Many thanks,
Gadi.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

眼藏柔 2024-08-27 18:45:48

JMeter 指南强烈建议使用预先生成的数据以获得良好的性能和准确性。

该任务可以通过 CSV 数据集配置组件完成(最佳实践 ,第 16.5 节)。主要思想是生成一个大的测试数据集,将其保存到文本文件,然后用作请求模板中的参数(每个请求的 CSV 文件行)。如果他/她愿意,可以将整个请求作为一个,并且仅作为参数。

请注意,JMeter 2.3.4(最新版本 atm)有一些限制:

  • 它不理解多行值(尽管 CSV 标准本身支持此类值),因此可能需要转义;
  • 它不理解列名称,因此可以仅按列位置关联变量(不幸的是,不能按逻辑名称)。

谢谢,
马克西姆

JMeter guidelines strongly recommend to use pre-generated data to have good perfomance and accuracy.

The task could be done via CSV Data Set Config component (Best Practices, section 16.5). The main idea is to generate a big test data set, save it to text file and then use as params in request template (line of CSV file per request). One can put whole request as one and only param if s/he wish.

Please be noted that JMeter 2.3.4 (latest version atm) has some restrictions:

  • it doesn't understand multiline values (though such ones supported by CSV standard itself), so escaping might be required;
  • it doesn't understand column names, so it is possible to associate variables by column position only (not by logical name unfortunately).

Thanks,
Maksim

┈┾☆殇 2024-08-27 18:45:48

您可以使用嵌套在 XML 中的 __Random 和 __char 函数将动态或随机数据插入到 XML 中。

这样每次发布 xml 时,值都是随机的。

基本上,只需定义您的 xml 结构并使用相互嵌套的 __random 和 __char 函数来随机创建任何随机文本/数字。
然后使用 __time 函数生成日期/时间数据。

you can insert dynamic or random data into the XML using __Random and __char functions nested in the XML.

So that everytime an xml is posted, the values will be random.

basically, just define your xml structure and use the __random and __char functions nested in each other to randomly create any random text/numbers.
Then use the __time function to generate date/time data.

掩耳倾听 2024-08-27 18:45:48

测试 Web 应用程序的另一种方法是使用 Badboy 等自动记录工具来记录您想要使用 Web 应用程序测试的步骤。然后您可以将相同的脚本传递给 Jmeter 进行测试。

您还可以将不同的值传递给脚本中的参数来测试不同的场景。
例如,您的应用程序具有带有用户名/密码字段的“登录页面”。然后,您可以在 1) 有效和 2) 无效登录凭据的情况下记录脚本。

然后在测试过程中您可以通过 CSV 传递不同的值或直接修改某些值
在录制的脚本中。

您可以在 http://www.badboy.com.au/ 找到有关 Badboy 的更多信息

Another approach to test web-application is use of automated recording tools like Badboy to record steps that you wanted to test with your web application. Then you can pass the same script to Jmeter for testing purpose.

You can also pass different values to parameters within script to test different scenarios.
For eg.Your application is having 'Login page' with username/password field. Then you can record the script in case of 1)valid and 2) invalid login credentials.

Then during testing you can pass different values through CSV or by modifying some values directly
in recorded script.

You can find more information about Badboy at http://www.badboy.com.au/

烟雨凡馨 2024-08-27 18:45:48

通过将其直接添加到 xml 中,在要随机化的标签上像这样为我工作:

numeric random ${__Random(0,10)}
字符串随机 ${__RandomString(3,ABCDEFGHIJKLMNÑOPQRSTUVWXYZ)}

Worked for me by adding it in the xml directly like this on the tag you want to randomize:

numeric random ${__Random(0,10)}
string random ${__RandomString(3,ABCDEFGHIJKLMNÑOPQRSTUVWXYZ)}

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