Allure installation, use, Jenkins integration

Table of contents

1. Introduction to allure

2. Install allure service

3. Install pytest and allure-pytest plugins

4. Generate a report

5. Other uses of allure

5.1 Add various attachments to the test report

5.2 Add use case title and description information

5.3 Add link

5.4 Marking Test Cases

5.5 Priority

Six, allure and jenkins integration

1. Introduction to allure

allure is an open source test report tool specially used to display test results. The report content is exquisite, beautiful and professional. allure can be integrated with many testing frameworks:

  • Java language, can be integrated with junit4, junit5, TestNG test framework;
  • Python language, can be integrated with pytest, behave, nose test framework;

allure will save the execution data of the test case into a json file, and then use allure's command line to convert the file into HTML and present it.

2. Install allure service

Github download address: https://github.com/allure-framework/allure2/releases

Unzip after downloading, and configure the decompressed bin path to the environment variable:

cmd to enter the command line, run allure --version, and a version number prompt will appear indicating that the allure service has been installed and configured.

3. Install pytest and allure-pytest plugins

1. Installation of pytest:

pip install pytest

2. Install the allure-pytest plugin:

pip install allure-pytest

4. Generate a report

1. When executing the pytest command, add the allure command parameter: --alluredir= test_report\allure (relative to the test report directory of the directory where the pytest command is located). After the command is executed, some files will be generated in the test_report\allure directory:

2. Use allure to generate a very beautiful html file:
execute directly in the pycharm command line or cmd: allure serve + report address (test_report\allure)

5. Other uses of allure

5.1 Add various attachments to the test report

语法:allure.attach(body, name, attachment_type, extension)

body:文件原始内容
name:带有文件名的字符串
attachment_type:附件类型,可在 allure.attachment_type 中查看支持的附件类型
extension:创建文件的扩展名
source:包含文件路径的字符串

5.2 Add use case title and description information

Syntax: @allure.title(str), @allure.description(str)

5.3 Add link

Syntax:
@allure.link(url, link_type, name=None): Provide a link address
@allure.issue(url, name=None): Provide a link with a small error icon
Using the above decorator will be in the "link" of the test report " section provides a clickable link to the URL:

5.4 Marking Test Cases

Syntax: @allure.epic, @allure.feature, @allure.story
@pytest.mark tags will not be displayed on the allure report, allure provides the above three types of mark decorators, they can be displayed on the allure report Yes, in the function column of the test report, the test cases will be displayed in categories.

@allure.epic()>@allure.feature()>@allure.story(), where story is a subset of feature, feature is a subset of epics, epic and feature will be displayed first on the test report, and story will be displayed after expansion .

When you want to run the specified story or feature or epics, you can use the following command line options to specify different test sets, and perform the operation

--allure-epics
--allure-features
--allure-stories
pytest.main([r'--alluredir=test_report\allure  --allure-stories story1,story2'])

5.5 Priority

Syntax: @allure.severity()

You can decorate functions, methods or entire classes with allure.severity_level enumeration values ​​as parameters, values ​​include:
BLOCKER, CRITICAL, NORMAL, MINOR, TRIVIAL

Run use cases with specified priority: --allure-severities+priority, if there are more than one, separate them with commas

pytest.main([r'--alluredir=test_report\allure  --allure-severities CRITICAL,NORMAL'])

Six, allure and jenkins integration

1. Install jenkins/system settings/plug-in management, install the Allure plug-in:

2. Global tool configuration – in Allure Commandline, install the allure command line tool:

3. Under System Configuration/Global Properties, add the allure installation directory:

4. Configure allure in the job and select allure report:

5. Build the project and view the allure report:

The above is the whole content of this article. If it is helpful to you, your support is the biggest motivation for the author to update~

If the article is helpful to you, remember to like, bookmark, and add attention. I will share some dry goods from time to time...

END Supporting Learning Resources Sharing

Finally:  In order to give back to the die-hard fans, I have compiled a complete software testing video learning tutorial for you. If you need it, you can get it for free 【保证100%免费】

Software Testing Interview Documentation

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.

insert image description here

How to obtain the full set of information:

Guess you like

Origin blog.csdn.net/m0_58026506/article/details/131228368