pytest+allure 使用记录

import time

import allure
import pytest
import os
# 1.pytest将在当前目录及其子目录中运行test _ * .py或* test.py形 式的所有文件。
# 2.以test_开头的函数,以Test开头的类,以test_开头的方法。所有包 package都要有__init_.py文件。

@allure.feature('我是主功能')
class TestCase():

    def test_01(self):
        print("测试数据")
        assert 'h' in 'hello'
        pass

    # @pytest.mark.skip
    @allure.story('我是子功能模块1')
    def test_02(self):
        print("跳过")

    # @pytest.mark.xfail
    @allure.story('我是子功能模块2')
    def test_03(self):
        print('定位为失败')
        assert 1==1
    @allure.step("我是一个大步骤")
    def test_04(self):
        with allure.step("我是一个小步骤的名字"):
            time.sleep(5)
            print("我会休眠5秒再执行")

    @allure.severity(allure.severity_level.BLOCKER)
    def test_05(self):

        print("我是重要级别的测试方法-会堵塞的")

    @allure.severity(allure.severity_level.TRIVIAL)
    def test_06(self):
        print('我是普通级别的测试方法')
        print('执行我时,需要输入  pytest -s -v 文件名 --allure-severities normal,critical ')

    def test_07(self):

        print('我下面会添加一个网页')
        allure.attach('<head></head><body>首页内容<body>','错误界面显示的内容',allure.attachment_type.HTML)

    def test_08(self):
        print('我会添加一个图片')
        allure.attach.file('001.png',attachment_type=allure.attachment_type.PNG)


if __name__ == '__main__':
    pytest.main(['-s','test_cs.py','--alluredir','temp/xml'])
    # os.system('allure generate ./temp -o ./temp/hmtl --clean')
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值