使用 ThreadCount TestNG 限制并行测试的数量 [英] Limiting the number of parallel tests with ThreadCount TestNG

查看:44
本文介绍了使用 ThreadCount TestNG 限制并行测试的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里头疼,我不知道如何处理.我有几个通过 xml 运行的测试类.大约 90 个测试类,每个类中包含大约 10 多个 @Test 步骤.我配置了一个 selenium 网格,带有 maxSession=5,因此在单个节点上并行运行的并行浏览器实例不能超过 5 个.这是我不明白的部分.假设我使用所有这些测试类启动这个 xml 文件,我设置了 thread-count=10 希望一次启动 10 个测试.发生的事情是我的所有测试类都开始了,它们不会在队列中等待(因为我认为将线程数设置为 10 就可以了)并且它们会跳过、超时、失败等等.我了解 maxSession 如何处理在网格上运行的内容,但是当 xml 启动时,我如何限制开始的测试类的数量,以免网格过载!

I have a head scratcher here and I do not know how to handle this. I have several test classes that run via xml. Around 90 test classes, each with about 10+ @Test steps inside them. I have a selenium grid configued, with a maxSession=5 so no more than 5 parallel browser instances can run parallel on a single node. Heres the part I do NOT understand. Lets say I kick off this xml file with all of these test classes, I set my thread-count=10 hoping that 10 tests will kick off at a time. What happens is ALL of my test classes start, they dont wait in a queue (as I thought setting a thread-count to 10 would do) and they skip, timeout, fail, whatever. I understand how maxSession can handle what gets run on the grid, but when the xml is kicked off how can I limit the the number of test classes starting so I dont overload the grid!

推荐答案

实际上 testNG 可以创建比 thread-count 中定义的多得多的线程.在接下来的情况下会发生这种情况(列表不准确):

Actually testNG can create much more threads than defined in thread-count. This happens in next cases (list is not exact):

  • 你有@DataProvider,parallel=true.每个调用的提供程序最多可以占用 dataproviderthreadcount 附加线程(因此,如果 thread-count=10 和 dataproviderthreadcount = 5,您将拥有多达 50 个线程)
  • 你有 @Test,threadPoolSize > 1 和 invocationCount > 1.每个这样的测试都会添加 min(threadPoolSize, invocationCount) 线程.

还要注意网格上的网络驱动程序测试超时.因为当你打电话

Also be careful with timeout for web-driver tests on grid. Because when you call

WebDriver wd = new RemoteWebDriver(...);

这将暂停您的测试执行,直到 grid-hub 为您提供空闲节点(默认情况下,hub 会永远等待,请参阅 newSessionWaitTimeout 参数).因此,即使测试的活动"阶段仅需要 120 秒,总测试持续时间可能会更长(取决于网格负载、测试类的结构、执行顺序等)

this will pause your test execution until grid-hub will have free node for you (by default hub waits forever, see newSessionWaitTimeout parameter). So even if 'active' phase of you tests takes only 120sec, total test duration can be much more (depends on grid load, on structure of your test classes, execution order etc)

这篇关于使用 ThreadCount TestNG 限制并行测试的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆