Content and usage of allure

Introduction to allureAllure is a lightweight and very flexible open source test reporting framework. It supports most t...

Introduction to allure
Allure is a lightweight and very flexible open source test reporting framework. It supports most testing frameworks, such as TestNG, Pytest, JUint, etc. It is simple to use and easy to integrate.

How does allure generate test reports
Add when running
pytest.main ( '–alluredir', 'report/result', 'TestDemo01.py'])
A report folder will be created in the current folder, and a result will be created under the report folder

Generate html test report
Because the generated test report is json and not good-looking, use this command to generate a good-looking HTML test report

After running, an HTML folder will be generated. Click index.html, which is our test report

#####

This section mainly records the content and usage of allure and how to make it generate a complete report.

Compared with other reports, the report generated by allure is the most readable and intuitive. This is not only the effect I want, but also the result many small partners want. After all, this is for the leaders, but also a summary of their boss's achievements.

For how to install, please move to:   https://www.cnblogs.com/Zhan-W/p/13132397.html

1, Allure related content:

Allure use case description usage method Parameter value Parameter description @allure.epic() epic description Define project, when multiple projects are used. Next is the feature @allure.feature() Module name Use cases are distinguished by modules. When there are multiple modules, give each module a name @allure.story() Case name Description of a use case @Allure.title (title of the use case) Use case title A use case title @allure.testcase() Connection address of test case Address of the function case storage system corresponding to the automation case @allure.issue() Defect address Corresponding to the defect address in the defect management system @allure.description() Use case description Detailed description of test cases @allure.step() Operation steps Operation steps of test cases @allure.severity() Use case level blocker ,critical ,normal ,minor ,trivial @allure.link() Define connection Used to define a connection that needs to be displayed in the test report @allure.attachment() enclosure Add test report attachment

The main ones are the above, and about half of them are commonly used.

2, Some common examples are as follows:

Code structure:

Login is a pre operation, which is stored separately after being taken out. The contents of the login.py file are as follows:

# __*__coding:utf-8 __*__ import allure @allure.step("Operation steps: Sign in") def longin(): '''Login operation''' print("This is the login interface")

The file conf test.py mainly contains some public contents

# __*__coding:utf-8 __*__ import pytest from common_contion.loging import longin @pytest.fixture(scope="session") def login_fixture(): longin() print("This is the pre operation: login")

case----test_ The case.py file mainly stores some test cases, as follows:

# __*__coding:utf-8 __*__ import pytest import allure from common_contion.dome_Interface import * @allure.severity("blocker") @allure.epic("entry name: Club resource management system") @allure.issue("http://149.335.82.12:8080/zentao/bug-view-1.html ") # Zen bug address @allure.testcase("http://149.335.82.12:8080/zentao/testcase-view-5-1.html ") # Zen use case connection address @allure.feature("Room management module") class Testdome1(object): def test_dome_1(self,login_fixture): '''Use case description of use case 1: I'm the first use case. I have only one step''' print("First test case") jieko_dome_1() def test_dome_2(self,login_fixture): '''Use case description of use case 2: I'm the second use case. I have only one step''' print("Second test case") jieko_dome_2() @allure.severity("critical") @allure.epic("entry name: Club resource management system") @allure.feature("Resource management module") @allure.story("Title of use case: Add, delete, modify and check Club resources") @allure.issue("http://149.335.82.12:8080/zentao/bug-view-1.html ") # Zen bug address @allure.testcase("http://149.335.82.12:8080/zentao/testcase-view-5-1.html ") # Zen use case connection address class Testdome3(object): def test_dome_3(self,login_fixture): '''Use case description of use case 3: I am the third use case, I have multiple steps;''' print("Third test case") f = jieko_dome_3() f.jieko_dome_3_1() f.jieko_dome_3_2() f.jieko_dome_3_3() f.jieko_dome_3_4()

common_ contion----dome_ The interface.py file mainly stores the interface contents related to the use case:

# __*__coding:utf-8 __*__ import allure def jieko_dome_1(): '''Use case description: Interface of use case 1''' print("This is the interface corresponding to the first use case") def jieko_dome_2(): '''Use case description: Interface of use case 2''' print("This is the interface corresponding to the second use case") @allure.feature("Resource management module") class jieko_dome_3(object): '''This is a module test''' @allure.step("Operation steps: Add resource personal information") def jieko_dome_3_1(self): '''Use case description: New content interface of use case 3''' print("This is the interface 1 corresponding to the third use case") @allure.step("Operation steps: Query resource online information") def jieko_dome_3_2(self): '''Use case description: Query content interface of use case 3''' print("This is the second interface corresponding to the third use case") @allure.step("Operation steps: Modify resource identity information") def jieko_dome_3_3(self): '''Use case description: Edit content interface of use case 3''' print("This is the interface corresponding to the third use case") @allure.step("Operation steps: Delete all resource information") def jieko_dome_3_4(self): '''Use case description: Delete content interface of case 3''' print("This is the fourth interface corresponding to the third use case")

3, Execute test cases:

Command line mode execution case

1,pytest --alluredir ./reopore/allure_row_1

Execution results:

  A is generated in the project  / reopore/allure_row_1, as shown in the figure:

2,dome>allure serve reopore/allure_row_1

After executing the command, load the collected data into the allure report. The execution results are as follows:

  The report opens automatically using the default browser

The report style is shown as follows:

  The above is the report style displayed after loading various decorators of allure.

28 November 2021, 16:19 | Views: 4764

Add new comment

For adding a comment, please log in
or create account

0 comments