1. pytest测试代码

import pytest
import allure


class Test_ABC:

        @pytest.fixture()
        def before(self):
                print("------->before")
                yield
                print("------->after")

        @allure.feature("分类1")
        def test_a(self, before):  # test_a方式传入了被fixture标识的函数,已变量的形式
                print("------->test_a")
                assert 1

        @allure.feature("分类1")
        def test_b(self):
                print("------->test_b")
                assert 1

        @allure.feature("分类2")
        def test_c(self):
                print("------->test_c")
                assert 1

        @allure.feature("分类2")
        @pytest.mark.parametrize(('x', 'y'),
                                 [(4, 4), (5, 5), (3, 3)])
        def test_simple_assume(self, x, y):  # 执行多个断言需要安装pytest-assume
                print("测试数据x=%s, y=%s" % (x, y))
                pytest.assume(x == y)
                pytest.assume(x + y > 2)
                pytest.assume(x > 1)
                print("测试完成!")


if __name__ == '__main__':
        pytest.main(['-s', 'test_demo.py', "--alluredir=report"])

2. jenkins设置

构建-执行shell下令

#!/bin/bash
/usr/local/bin/pytest -s -q --alluredir=/Users/xxx/Documents/myjenkins/workspace/test_allure/report_test --clean-alluredir /Users/xxx/Documents/myresource/test/test_demo.py  
/usr/local/bin/allure generate --clean /Users/xxx/Documents/myjenkins/workspace/test_allure/report_test -o /Users/xxx/Documents/myjenkins/workspace/test_allure/report_test2

3. allure设置

需要安装Allure插件

,

欧博开户ALLbet6.com

欢迎进入欧博开户平台(Allbet Game):www.aLLbetgame.us,欧博开户平台开放欧博Allbet开户、欧博Allbet代理开户、欧博Allbet电脑客户端、欧博AllbetAPP下载等业务。

,