我使用 pytest-repeat 多次执行我的 selenium 脚本。我需要在执行过程中捕获迭代次数并利用它。
我探索了 pytest.mark、pytest.collect 和 pytest.Collector
class Testone():
@pytest.fixture()
def setup(self):
@pytest.mark.repeat(RowCount)
def test_create_eq(self,setup):
这里需要捕获迭代次数。
我认为应该有比我下面描述的更简单直接的方法。pytest-repeat
有固定装置__pytest_repeat_step_number
我希望它可以提供测试的当前步骤号,但它没有。
request.node.name
提供生成的测试函数的名称pytest_repeat
它有步骤号,可以根据您的目的提取该步骤号。
import pytest
class Testone():
@pytest.fixture()
def setup(self):
pass
@pytest.mark.repeat(4)
def test_create_eq(self,setup,request):
current_step = request.node.name.split('[')[1].split('-')[0] #string form; parse to int, if required
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)