python鄙视链:pytest>uniitest>rebotframe>流水账>hello word

进了新公司,本来用unittest框架做自动化的,但是因为报告不美观,比不上allure,被老板要求要使用pytest框架。才知道原来还有这么一条鄙视链。

还有什么可说的呢?盘它

1.安装

pip install -U pytest 

 

pytest 运行规则:文件名和函数都以test_开头。测试类以Test开头,且不能有__init__方法。断言assert.

 

下载allurehttps://github.com/allure-framework/allure2/releases,把解压后的 bin 目录添加到环境变量的 PATH 中。

#test.py  
#the content of test.py
import pytest
import csv,os
path=os.getcwd()
# print(path)
datapath=path+"\config\config1.csv"
# print(datapath)
file=open(datapath,"r")
table=csv.reader(file)
for row in table:
if row[1]=="1":
print(row[0])
# pytest.main([row[0],"-s", "--html=test_result/"+row[2]])
pytest.main([row[0], "-s", "-q","--alluredir=test_result/xml"])

打开命令行,切换到项目下,执行  python test.py  ;   

allure generate test_result/xml -o test_result/html --clean
posted on 2020-04-06 21:13  Jessica1203  阅读(107)  评论(0编辑  收藏  举报