这个问题与this非常相似。但是,我没有任何要传入的参数(使用参数化装饰器)。
看看我是如何使用这个测试的。
@pytest.fixture(scope='module')
def driver(headless=True):
opts = webdriver.FirefoxOptions()
opts.add_argument('--headless') if headless else None
driver = webdriver.Firefox(options=opts)
driver.get('http://localhost:8080/request')
yield driver
driver.quit()
#@pytest.mark.parametrize(ids="test the title of web page, further info: blah blah..")
def test_title(driver):
"""
title of request page
"""
driver.get('http://localhost:8080/request')
assert driver.title == 'abc', "failed for: test title of web page'"
注释的参数化装饰器失败,因为存在非可选参数。有没有办法将这个简单的描述添加到测试中,并在测试失败时显示出来。