美文网首页
Pytest+Allure搭建接口框架(二)

Pytest+Allure搭建接口框架(二)

作者: Aaron_fcff | 来源:发表于2019-04-26 13:59 被阅读0次

    前言:学习笔记一已经配置好allure报告的环境了,现在开始更多的实践......

    一、熟悉各个allure的用法

    import allure
    import pytest
    
    
    @allure.feature('后台项目')
    @allure.story('充值')
    class TestPlatform:
    
        @allure.step('步骤一')
        def test_one(self):
            """
            这是步骤一的描述
            """
            print('a')
            assert 0 == 1
    
        @allure.step('步骤二')
        def test_two(self):
            """
            这是步骤二的描述
            """
            print('a')
            assert 1 == 1
    
    
    @allure.feature('钱包项目')
    @allure.story('消费')
    class TestHome:
    
        @allure.severity('critical')
        @allure.step('步骤一')
        def test_she(self):
            """
            这是步骤一的描述
            """
            print('a')
            assert 0 == 1
    
        @allure.step('步骤二')
        def test_he(self):
            """
            这是步骤二的描述
            """
            print('a')
            assert 1 == 1
    
    
    if __name__ == '__main__':
        pytest.main(['-s', '-q', '--alluredir', '/Users/pundix047/Documents/Xwallet'])
    

    然后,再用allure命令生成好看的测试报告

    allure generate 测试数据xml -o 测试报告目录 --clean
    

    其中-o是指向目标生成测试报告的目录;--clean是生成一个全新的测试报告(覆盖上一次的结果)


    image.png
    image.png

    相关文章

      网友评论

          本文标题:Pytest+Allure搭建接口框架(二)

          本文链接:https://www.haomeiwen.com/subject/cvxtnqtx.html