0

I am using pytest to run appium tests with python-appium.

I run the tests on different devices, and I use a command line parameter to select the device via pytest_addoption.

I output the test results via --junitxml. Afterwards I collect the test results in jenkins.

It would be really useful if the test names would be prefixed with the platform name.

How can this be done in py.test?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Nathan
  • 7,099
  • 14
  • 61
  • 125

1 Answers1

0

An easy way to modify a test name is to add a parameter to a fixture.

So now I do:

@pytest.fixture(scope="session", params= pytest.devices)
def env():
    ...

and in my 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')]
Nathan
  • 7,099
  • 14
  • 61
  • 125