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.pyimport pytestimport csv,ospath=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
来源:https://www.cnblogs.com/keepinpace/p/12649036.html