A complete tutorial for python Pytest to generate alluer test reports

1. Download the allure package locally and unzip it

There is a lot of information on the Internet, which is not provided here.

insert image description here

2. Configure environment variables

Copy the path of the bin file after decompression above, and add it to the environment variable Path
insert image description here

3. Verify that the environment variable configuration is successful

Enter allure in cmd and press Enter. Check if allure is successful:
insert image description here
insert image description here

4. Install the allure plugin in pycharm

Add through the interface, or add through the command line: pip install allure-pytestinsert image description here

5. Write pyton scripts, execute files, and generate allere test reports

Run the script command based on pytest:
–alluredir can be followed by specifying the report storage path;

if __name__ == '__main__':
    # 运行指定用例文件
    pytest.main(['tests\\test_org_manage.py', '--alluredir=output'])

After the script is executed, the generated report is not an html page, but some json files.
insert image description here
If you want to view the html file, you need to start the service (run the command line in the current directory): allure serve output
insert image description here
The most beautiful and elegant allure test report recognized by the industry is born, and the effect is as follows:
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/weixin_48415452/article/details/129305741