Table of contents
Customized allure test report effect display
How to customize the output of the icing on the cake allure test report
Before using it, import the allure module.
Before use, familiarize yourself with allure command line parameters for running test cases
1, feature - test case features (main functional modules): generally on the class
2, story - branch function under the feature function module: generally in terms of method
3, severity - the severity level of the test case
4, step - the steps of the test case
7. description - use case description
foreword
Today, I will show you how to generate a beautiful allure test report, and I hope it can help you.
Customized allure test report effect display
How to customize the output of the icing on the cake allure test report
Before using it, import the allure module.
import allure
Before use, familiarize yourself with allure command line parameters for running test cases
--allure-severities=SEVERITIES_SET
--allure-epics=EPICS_SET
--allure-features=FEATURES_SET
--allure-stories=STORIES_SET
--allure-ids=IDS_SET Comma-separated list of IDs.
--allure-link-pattern=LINK_TYPE:LINK_PATTERN
--alluredir=DIR Generate Allure report in the specified directory (may
--clean-alluredir Clean alluredir folder if it exists
--allure-no-capture Do not attach pytest captured logging/stdout/stderr to Allure Report
1, feature - test case features (main functional modules): generally on the class
Usage: @allure.feature()
Test case executions can be filtered out based on feature characteristics:
pytest test_allure.py --allure-features="login module" -vs
2, story - branch function under the feature function module: generally in terms of method
Usage: @allure.story()
Test case executions can be filtered out based on the story feature:
pytest test_allure.py --allure-stories="Login failed" -vs
If you want to execute multiple stories or features, add "," in the middle of multiple story names or feature names:
pytest test_allure.py --allure-stories="Login failed", "Logout failed" -vs
【Notice】
① When --allure-features and --allure-stories are used at the same time, if the use case in --allure-features includes the use case of --allure-stories, only the use case of --allure-features will be executed; if not, execute --allure at the same time Use cases for -features and --allure-stories.
②Although running test cases through pytest -m command line parameters can also achieve the purpose of running test cases in groups; but using the allure feature to achieve group running test cases can also be displayed in the allure report, making the allure feature more intuitive.
3, severity - the severity level of the test case
Scenario: Usually, the tests include scenarios such as smoke test and verification online test, which are executed according to the level of importance. For example, the main process and important modules should be run through before going online.
Solution: Attach tags by adding allure.severity on methods, functions and classes.
Execute: pytest filename --allure-severities=normal -vs
The definition of severity level in Allure:
- blocker level: interrupt defect (the client program is unresponsive and cannot perform the next operation)
- critical level: critical defect (missing function point)
- normal level: normal defect (numerical calculation error)
- Minor level: minor defects (interface errors do not match UI requirements)
- trivial level: minor defects (must have no prompts, or the prompts are not standardized)
How to use: @allure.severity(allure.severity_level.CRITICAL) or @allure.severity('critical')
4, step - the steps of the test case
Instructions:
① @allure.step() can only be placed on a class or method in the form of a decorator
② with allure.step() : can be placed in the test case method, but the code of the test step needs to be included in the statement
5, attach - used to enter some additional information into the test report, usually some test data information
Usage: allure.attach(body, name, attachment_type, extension)
parameter:
body
- the original content to be written to the filename
- a string containing the filenameattachment_type
- one of theallure.attachment_type
valuesextension
- The provided extension will be used as the created file
6. link/issue/testcase - link
Instructions:
- @allure.link()
- @allure.issue()
- @allure.testcase()
7. description - use case description
Instructions:
- @allure.description() provides a decorator for a description string
- @allure.description_html() provides some HTML in the description section of the test case
Epilogue
This post ends here, and finally, I hope that friends who read this post can gain something.
If you think the article is , share, and leave a message , because this will be the strongest motivation for me to continue to output more high-quality articles!