1

我有一个 3 的类tests,我正在使用pytestSelenium-Webdriver 运行我的测试来执行 UI 操作。

class abc:
  def test_1(self):
      print("I am test_1 open browser and perform operations")
  def test_2(self):
      print("I am test_2 open browser and perform operations")
  def test_3(self):
      print("I am test_3 open browser and perform operations")

每个测试都会打开Chrome浏览器实例以执行一组 UI 操作。现在我想一次性运行上述所有测试。所以理想情况下pytest应该同时打开三个Chrome浏览器实例。(我读过 xdist 插件,但我认为它用于在不同平台上运行测试)

请提供您的意见。

4

1 回答 1

2

但我认为这是用于在不同平台上运行测试

不,您可以xdist用于一个平台并且完全符合您的描述。

你需要做的是,你只需要在运行时给出这样的命令:

pytest -n <NUM>

<NUM>并行工作者的数量在哪里。如果你通过喜欢,

pytest -n3

它将并行运行 3 个测试。

于 2017-10-17T07:46:47.307 回答