The steps to use allure are as follows:
1. Generate allure test report through DOS window command:
1. Switch to the pytest test case path in the command mode and execute the command: py.test test file --alluredir=report path to generate an xml report
2. Execute the command in command mode: allure generate xml report path -o html report path to generate a web version of the test report
3. In the html report path, open the index.html file to display the report
2. Generate allure test report through pytest: (recommended)
Code example:
import os
import pytest
class TestDome_09:
def test_case_01(self):
print("----- 用例01 -----",end=" ")
assert True
@pytest.mark.skip('无条件跳过')
def test_case_02(self):
print("----- 用例02 -----",end=" ")
assert True
def test_case_03(self):
print("----- 用例03 -----",end=" ")
assert True
def test_case_04(self):
print("----- 用例04 -----",end=" ")
assert True
if __name__ == '__main__':
# 生成json文件
pytest.main(['-s','-v','--alluredir=./allure_json_path','--clean-alluredir'])
# 生成html文件
os.system('allure generate %s -o %s --clean'%("./allure_json_path","./allure_html_path"))
Execution effect:
Display of directory files in pycharm:
Report performance: