初识pytest, allure

# _*_ coding: utf-8 _*_
# __author__: slv
# 2020/8/26

import pytest
import os

#此代码用例生成报告成功
#注意:class以Test开头,method和function要以test开头或者结尾,测试文件也要以test开头或者结尾
class Test1:
def test_1(selfs):
assert 1 == 1
#给test_2传入一个参数,总共传3次
@pytest.mark.parametrize('a', [1, 2, 3])
def test_2(self, a):
assert 1 == a

#给test_3传入3个参数a,b,c,总共传3次不同的值
@pytest.mark.parametrize('a,b,c', [(1, 2, 3), (3, 3, 7), (4, 4, 8)])
def test_3(self, a, b, c):
assert a + b == c


if __name__ == '__main__':
#执行测试文件,并且使用allure生成报告
pytest.main(['20200826_pytest.py','-s','--alluredir','../report'])
#调用系统命令,使用allure生成html的报告
os.system('allure generate ../report -o ../report/report --clean')
posted @ 2020-08-26 11:30  RoseLv  阅读(216)  评论(0)    收藏  举报