使用 Jmeter 和 Junit 进行负载测试时,setUp 和tearDown 如何工作?

发布于 2024-10-07 03:26:19 字数 282 浏览 1 评论 0原文

我必须对正在使用 Jmeter 和 Junit 进行负载测试的数据库进行一些设置和清理。我已将它们分别放入setUp和tearDown中。我现在的问题是,当我触发 100 个执行测试的线程时会发生什么? Jmeter 会首先运行 100 个设置,然后运行 ​​100 个测试线程,最后运行 100 个拆卸吗?或者它只是创建 100 个线程来执行我的测试并并行运行它们?

我担心的是,setUp 和tearDown 可能会影响我的测试,具体取决于Jmeter 和Junit 的工作方式。在这种情况下,我必须完全在测试之外进行设置和拆卸。

I have to do some setup and cleanup on the database I am load testing with Jmeter and Junit. I have put these in setUp and tearDown respectively. My question now is what happens when I fire off 100 threads that execute my test? Will Jmeter first run 100 setUp's, then 100 threads of my test and then 100 tearDowns? Or does it just create 100 threads to execute my test and run them all in parallel?

My concern is just that the setUp and tearDown may affect my testing, depending on how Jmeter and Junit do things. In that case, I would have to do setUp and tearDown completely outside of my test.

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

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

发布评论

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

评论(2

誰ツ都不明白 2024-10-14 03:26:19

我没有一起使用过 Junit 和 Jmeter,所以我假设 setUp 和tearDown 是 Junit 的一部分。

鉴于此,我假设 Junit 将执行 setUp,运行 Jmeter 脚本,然后在 Jmeter 发出完成信号时运行 TeaDown。由于 JMeter 对多个线程使用相同的脚本,并且直到最后一个线程完成才“完成”,因此您不应该有多个设置/拆卸脚本。

我会尝试使用 2 个线程,看看会发生什么。

I haven't used Junit and Jmeter together, so I'm assuming setUp and tearDown are part of Junit.

Given that, I would assume Junit would execute setUp, run the Jmeter script then run tearDown when Jmeter signals it is done. Since JMeter uses the same script for multiple threads, and isn't "done" until the last thread finishes, you shouldn't have multiple setUp/teardown Scripts.

I would try it with 2 threads and see what happens.

爱人如己 2024-10-14 03:26:19

计算采样器的运行时间时,不考虑执行设置和拆卸的时间。仅测量测试方法本身的执行时间 - 因此从报告的角度来看它没有任何区别

The time to perform the setUp and tearDown isn’t taken into account when calculating the sampler’s elapsed time. Only the execution time of the test method itself is measured - so from a reporting point of view it doesn’t make any difference

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