根据命令行参数修改测试名称

时间:2017-04-09 20:46:20

标签: python appium pytest python-appium

我正在使用pytest使用python-appium运行appium测试。

我在不同设备上运行测试,并使用命令行参数通过pytest_addoption选择设备。

我通过--junitxml输出测试结果。之后我在詹金斯收集测试结果。

如果测试名称将以平台名称为前缀,那将非常有用。

如何在py.test中完成?

1 个答案:

答案 0 :(得分:0)

修改测试名称的简便方法是将参数添加到灯具中。

现在我这样做:

@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')]
相关问题