我有一个3 tests
的课程,我正在使用pytest
运行我的测试,使用Selenium-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插件,但我认为它用于在不同平台上运行测试)
请提供您的意见。
答案 0 :(得分:2)
但我认为用于在不同平台上运行测试
不,您可以将xdist
用于一个平台以及您所描述的内容。
你需要做的是,你只需要在运行时给出这样的命令:
pytest -n <NUM>
其中<NUM>
是并行工人的数量。如果你传递的话,
pytest -n3
它将并行运行3次测试。