【问题标题】:Modify test names based on command line parameters根据命令行参数修改测试名称
【发布时间】:2017-09-04 19:46:03
【问题描述】:
我正在使用 pytest 通过 python-appium 运行 appium 测试。
我在不同的设备上运行测试,我使用命令行参数通过pytest_addoption选择设备。
我通过--junitxml输出测试结果。然后我在jenkins中收集测试结果。
如果测试名称以平台名称为前缀,那将非常有用。
如何在 py.test 中做到这一点?
【问题讨论】:
标签:
python
appium
pytest
python-appium
【解决方案1】:
修改测试名称的一种简单方法是向夹具添加参数。
所以我现在这样做:
@pytest.fixture(scope="session", params= pytest.devices)
def env():
...
在我的 conftest.py 中:
def pytest_addoption(parser):
parser.addoption("--device", action="store",
help="the device to use")
def pytest_configure(config):
pytest.devices = [config.getoption('--device')]