模块六 测试报告定制

 

 

 

 

 

学习文档

https://docs.qameta.io/allure/#

安装allure-pytest

 

 

 

 

 

 生成测试报告需要两个步骤:

① 生成测试报告

pytest --alluredir=./result/1

(执行路径result/1下)

② 打开测试报告:

allure serve ./result/1

 

 

 

 

 

 希望在报告中看到测试功能,子功能,测试步骤,包括测试附加信息

测试功能  

allure.features("登录模块")
class TestLogin:
    @allure.story("登录成功")
    def test_login_success(self):
        print("这是登录:测试用例,登录成功")
        pass

子功能 

class TestLogin:
    @allure.story("登录成功")
    def test_login_success(self):
        print("这是登录:测试用例,登录成功")
        passc

 测试步骤

    def test_login_failure(self):
        with allure.step("点击用户名"):
            print("输入用户名")
        with allure.step("点击用户密码"):
            print("输入密码")
        print("点击登录")

        with allure.step("登录登录之后登录失败"):
            assert 1 == 1
            print("登录失败")
        pass 

如果只测试登录功能运动的时候可以加限制过滤:

pytest  文件名  --allure-features "登录功能"

allure generate ./result/ -o ./report/ --clean

打开测试报告

allure open -h 127.0.0.1 -p 8883 ./report/

 

 

 feature/story

 

 

 

 

 

 

# Author:Han
# python:3.9
import  allure

@allure.link("https://se.hundsun.com/browse/TZCSII-3266?filter=-2",name = '缺陷记录平台')
def test_with_link():
    print("这是一条加了链接的测试")
    pass

  

 

 

 

 

posted on 2021-01-25 21:06  Cc01  阅读(67)  评论(0编辑  收藏  举报

导航