1、我们需要从新创建一个文件,引入pytest、allure、os包,进行编写
import pytest,allure,os
class Test01(object):
@allure.feature('购物车')
@allure.story('产品展示')
def test01(self):
with allure.step('查看凯迪拉克系列的信息'):
allure.attach('XT6','XT5')
with allure.step('查看布加迪系列信息'):
allure.attach('布加迪Vision GT','威航')
if __name__ == '__main__':
pytest.main(['--alluredir', 'report/result', 'test_allures.py'])
split = 'allure ' + 'generate ' + './report/result ' + '-o ' + './report/html ' + '--clean'
os.system(split)
2、点击运行,在左侧会出现result文件夹
3、点击result中的index,点击浏览器进行访问
4、点击test_allures
5、可以看到效果展示