TestNG 如何使用多线程调用测试方法?

发布于 2024-09-30 08:47:14 字数 561 浏览 0 评论 0原文

在 TestNG 文档中,有一节描述了如何告诉 TestNG 使用多个线程调用测试方法:

您还可以指定 @Test 方法应该从调用 不同的线程。您可以使用 属性threadPoolSize来实现 这个结果:

@Test(threadPoolSize = 3, invocationCount = 10,  timeOut = 10000)
public void testServer() {

在此示例中,函数 testServer 将被调用十次 来自三个不同的线程。强调我的

我的问题是上面的文本是否意味着

  1. 该方法将总共运行 使用 3 个线程运行 10 次
  2. 该方法将总共运行 30 次,其中 3 个线程各运行该方法 10 次。

我的想法是,因为调用计数与方法相关联,所以 1 是正确的解释,但如果我错了,我将不胜感激。

In the TestNG documentation, there is a section describing how to tell TestNG to invoke test methods using multiple threads:

You can also specify that a @Test
method should be invoked from
different threads. You can use the
attribute threadPoolSize to achieve
this result:

@Test(threadPoolSize = 3, invocationCount = 10,  timeOut = 10000)
public void testServer() {

In this example, the function testServer will be invoked ten times
from three different threads.
(emphasis mine)

My question is whether the text above means that

  1. the method will be run a total of
    10 times using 3 threads or
  2. the method will be run a total of 30 times, with 3 threads running the method 10 times each.

My thought is that because the invocation count is associated with the method, 1 is the correct interpretation, but I would appreciate being corrected if I'm wrong.

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

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

发布评论

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

评论(2

写下不归期 2024-10-07 08:47:14

是的,1 是正确答案。

作为旁注,编写一个快速测试用例来验证这个假设可能比写下问题更快:-)

Yes, 1 is the correct answer.

As a side note, writing a quick test case to verify this hypothesis would probably have been faster than writing up the question :-)

鸩远一方 2024-10-07 08:47:14

使用 @Test(threadPoolSize = 3, invokingCount = 10, timeOut = 10000) ,它在多个线程中运行异步测试。

你可以看一下: http://www. asjava.com/testng/testng-tutorial-time-test-with-annotation-timeout/

Use @Test(threadPoolSize = 3, invocationCount = 10, timeOut = 10000) , which run asynchronous tests in multiple threads.

you may take a look: http://www.asjava.com/testng/testng-tutorial-time-test-with-annotation-timeout/

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