pytest framework -- allure report use case parameters detailed explanation

Original link, thanks to the author: http://www.manongjc.com/detail/18-uxknglitylthfjx.html

1. Test case:

#test_allure_demo.py
import pytest
import allure
@pytest.fixture(scope="session")
def login():
    print("前置条件:登录")

@allure.step("步骤1")
def step_1():
    print("操作步骤----1")

@allure.step("步骤2")
def step_2():
    print("操作步骤----2")

@allure.step("步骤3")
def step_3():
    print("操作步骤----3")

@allure.epic("epic对大story的一个描述性标签")
@allure.feature("测试模块")
class TestC:
    @allure.testcase("http://www.tc.com")
    @allure.issue("https://www.bug.com/")
    @allure.title("测试用例的标题")
    @allure.story("用户故事:1")
    @allure.severity("blocker")
    def test_1(self,login):
        '''我是用例1的描述内容,看的见我不'''
        step_1()
        step_2()

    @allure.story("用户故事:2")
    def test_2(self,login):
        print("测试用例2")
        step_1()
        step_3()
@allure.epic("epic对大story的一个描述性标签")
@allure.feature("模块块2")
class TestC2():
    @allure.story("用户故事:33")
    def test_3(self,login):
        print("测试用例test_3")
        step_1()

    @allure.story("用户故事:44")
    def test_4(self,login):
        print("测试用例test_4")
        step_3()  

2. Execute and open the report:
Execute the use case: pytest -vs test_allure_demo.py --alluredir ./report/a ,
insert image description here
open the report: allure serve ./report/a
insert image description here
3. Allure report page
insert image description here
4. Execute the use case on demand:
a. Select Run the use case you want to implement epic:
pytest --alluredir ./report/allure --allure-epics=epic A descriptive label for the big Story
b. Choose to run the use case you want to implement features:
pytest --alluredir ./report /allure --allure-features=module block 2
c. Choose to run the use case you want to implement features:
pytest --alluredir ./report/allure --allure-stories="User story: 1"

Guess you like

Origin blog.csdn.net/weixin_45422695/article/details/121775307