Use case description related methods of allure test report; as shown in the figure below
allure mark use case level severity
In the process of automated testing, when there are more and more test cases, if a round of testing is performed and several tests fail, we also hope to quickly calculate the level of defects.
pytest combined with the allure framework can make a detailed division of the level of use cases.
Allure divides the levels of use cases into five levels:
- blocker blocking defect (the function is not implemented, the next step cannot be performed)
- critical Serious defect (missing function point)
- normal General defects (borderline cases, malformed)
- minor Minor defects (interface errors do not match ui requirements)
- trivial Minor defects (must have no prompts, or prompts are not standardized)
Writing method one:
@allure.severity("blocker")
@allure.severity("critical")
@allure.severity("normal")
@allure.severity("minor")
@allure.severity("trivial")
Writing method two:
@allure.severity(allure.severity_level.Blocker)
@allure.severity(allure.severity_level.critical)
@allure.severity(allure.severity_level.normal)
@allure.severity(allure.severity_level.Minor)
@allure.severity(allure.severity_level.Trival)
If you want to execute use cases according to the use case level, you can use the following parameters:
allure command line parameter allure-severities
pytest --alluredir=./report/allure --allure-severities=blocker
pytest --alluredir=./report/allure --allure-severities=blocker,critical
The execution code is as follows:
import os import pytest # Filter according to priority --allure-severities=blocker,normal pytest.main(['-s','-v','--alluredir=./allure_json_path','--clean-alluredir' ,'--allure-severities=blocker']) os.system('allure generate %s -o %s --clean'%('./allure_json_path','./allure_html_path'))
Common Concepts in Agile Models
allure test report use case description related methods actual combat
1. Use the pycharm tool to create a new project test_suites, and create a new login_module module and product_module module in this directory, as shown in the figure below
2. Create a new test_login.py file under the login_module module
code show as below:
import allure # How to write use case steps 1. Use case steps can be written in the public layer @allure.step('Step 1: Open the login interface of Dingdang e-commerce') def step_01(): pass # epic project name [email protected] ('[ epic] Dingdang e-commerce system') # feature project version @allure.feature('[feature] Dingdang e-commerce system_V1.0') class TestLogin: # use case module @allure.story('[story] user login Module') # Use case title @allure.title('[Title] Verify that the correct user name and password can be successfully logged in') # Manage the link address of the test case @allure.testcase(url='http://47.107.187.45/ zentao/www/index.php?m=testcase&f=view&caseID=17&version=1',name='use case connection') # Link address of management defects @ allure.issue(url='http://47.107.187.45/zentao/ www/index.php?m=bug&f=browse&productID=4',name='Defect address')defect address') # use case description @allure.description('Login test case executor: Xiaobai') # Define a link @allure.link(url='https://www.baidu.com/',name='Baidu Search') # use case Level blocker, critical, normal, minor, trivial # @allure.severity('normal') # Use case level writing method 1 # Use case level blocker, critical, normal, minor, trivial @allure.severity(allure.severity_level.BLOCKER) # Use case Level writing method 2 def test_login_case_01(self): step_01() # Use case step writing method 2 Use case steps can be written inside the method with allure.step('Step 2: Enter user name admin'): pass with allure.step('Step 3: Enter password 123456'): pass # @allure.attach report add attachment with open('C:/Users\Jeff\PycharmProjects\APP_AUTO_DEMO/test_suites\login_module/test.jpeg', 'rb') as img_file: img_file_obj = img_file.read() allure.attach(img_file_obj, 'test error screenshot img_file_obj = img_file.read() allure.attach(img_file_obj,'test error screenshot',allure.attachment_type.JPG) print("TestLogin test_login_case_01",end=' ') assert True @allure.story('[story] user login Module') @allure.title('[Title] Verify that the wrong username and password can be handled correctly') def test_login_case_02(self): print("TestLogin test_login_case_02",end=' ') assert True
3. Create a new test_product.py file under the product_module module
code show as below:
import allure @allure.epic('[epic] Dingdang e-commerce system') @allure.feature('[feature] Dingdang e-commerce system_V1.0') class TestProduct: @allure.story('[story] Product module') @allure.title('[Title] verified that the product can be successfully added to the shopping cart') def test_product_case_01(self): print("TestProduct test_product_case_01",end=' ') assert True @allure.story('[ story] commodity module') @allure.title('[Title] verify that the product can be paid successfully') def test_product_case_02(self): print("TestProduct test_product_case_02",end=' ') assert True
4. Create a new execution file run_cases.py in the root directory of the project test_suites
code show as below:
import os import pytest pytest.main(['-s','-v','--alluredir=./allure_json_path','--clean-alluredir']) os.system('allure generate %s -o %s --clean'%('./allure_json_path','./allure_html_path'))
5. Execute the run_cases.py file and generate two directory folders allure_json_path and allure_html_path under the project test_suites directory
The json data source of the allure test report is generated under the allure_json_path directory
The allure test report html is generated under the allure_html_path directory
As shown below:
Use Google Chrome to open the index.html file in the allure_html_path directory; as shown below