当前位置: 首页 > news >正文

无锡装饰网站建设wordpress 课程激活

无锡装饰网站建设,wordpress 课程激活,wordpress页面和文章,白色网站源码创建测试用例和测试结果集文件夹#xff1a; excel编写的接口测试用例如下#xff1a; 1 encoding 响应的编码格式。所测项目大部分是utf-8#xff0c;有一个特殊项目是utf-8-sig 2 params 对应requests的params 3 data#xff0c;对应requests的data 有些参数是动态的 excel编写的接口测试用例如下 1 encoding 响应的编码格式。所测项目大部分是utf-8有一个特殊项目是utf-8-sig 2 params  对应requests的params 3 data对应requests的data 有些参数是动态的写参数名程序中用eval()函数转化 baseapi.py #-*-coding:utf-8-*-接口基类 dinghanhua baseapi.py import requests from requests.cookies import RequestsCookieJarclass apitest:def __init__(self):self.cookies RequestsCookieJar()def response_text(self,method,url,encodingutf-8,**kwargs):请求函数response requests.request(method,url,cookiesself.cookies,**kwargs)self.cookies.update(response.cookies) #更新cookiesif encoding: # 如果有响应编码则配置编码response.encoding encodingresult response.textreturn result runtest.py #-*-coding:utf-8-*-读取excel用例并执行 dinghanhua import xlrd from xlutils.copy import copy from baseapi import apitest import datetime import os import re import logging;logging.basicConfig(levellogging.INFO)def run_testcase(excelpath,sheetindex0):# region 读取excel和sheetbook xlrd.open_workbook(excelpath) # 打开exceltry:sheet book.sheet_by_index(sheetindex) # 读取sheetwb copy(book) # 转变成xlwt book对象wsheet wb.get_sheet(sheetindex)except IndexError:logging.info(读取的sheet不存在)raise IndexError(读取的sheet不存在)#endregion# region 读取和运行用例testapi apitest()fail 0 # 用例执行失败个数success 0 # 用例执行成功个数for row in range(1, sheet.nrows):isrun str(int(sheet.cell_value(row,8))).strip() # 是否运行if isrun 1: # 判断用例是否运行运行则读取其他字段label str(sheet.cell_value(row, 1)).strip()method str(sheet.cell_value(row,2)).strip()url str(sheet.cell_value(row, 3)).strip()encoding str(sheet.cell_value(row, 4)).strip()headers str(sheet.cell_value(row, 5)).strip()params str(sheet.cell_value(row, 6)).strip()data str(sheet.cell_value(row, 7)).strip()checkpoint str(sheet.cell_value(row, 9)).strip()try:params eval(params) # 参数转变 从字符串转变成字典或带入参数转变不了则不处理except:passtry:data eval(data)except:passtry:headers eval(headers)except:passactual_result testapi.response_text(methodmethod,urlurl,paramsparams,datadata,encodingencoding,headersheaders) # 获取响应if re.search(checkpoint,actual_result): #测试通过写excel 测试通过计数加1wsheet.write(row,10,pass)success 1logging.info(labeltest pass)else: #测试不通过写excel 测试不通过计数加1wsheet.write(row,10,fail)wsheet.write(row,11, actual_result) # 写入响应fail 1logging.info(%s test fail.检查点%s,响应结果%s%(label,checkpoint,actual_result))# endregion# region 保存测试结果filepath os.path.join(os.path.dirname(__file__),testresult) # 测试结果目录if not os.path.exists(filepath): # 目录不存在则创建os.mkdir(filepath)filename os.path.join(filepath,datetime.datetime.now().strftime(%Y%m%d%H%M%S%f).xls) # 测试结果文件wb.save(filename) # 保存文件logging.info(测试结果测试通过%s测试不通过%s。测试结果文件路径%s%(success,fail,filename))# endregion#执行测试用例# 测试要用的动态参数 nowtime datetime.time().strftime(%Y%m%d%H%M%S%f) # 时间戳 today str(datetime.date.today()) # 当前日期 newdate (datetime.datetime.now()-datetime.timedelta(minutes30)).strftime(%Y-%m-%d %H:%M:%S) # 当前时间点前半小时 sso test # sso串 id 1 # id token token # token通过抓包获取excelpath rC:\Users\dinghanhua\PycharmProjects\ApiTest\testcase\testcase1.xlsx # excel用例文件 run_testcase(excelpathexcelpath,sheetindex1) # 逐条读取并运行用例 运行之后testresult文件夹下查看已生成的测试结果文件文件名测试运行时间戳 该项目用jmeter、postman也可以做接口测试。用python脚本可以用excel写好用例直接执行。脚本中的检查点等可根据实际项目再调整。
http://www.dnsts.com.cn/news/187150.html

相关文章:

  • 肥城网站制作企业信息查询系统官网上海
  • 网站设计经典案例建设工程机械鉴定中心官网
  • 太原零元网站建设wordpress投票
  • 连云港网站建设2345推广联盟
  • 网站建设公司代理idc科技公司网站模板
  • 国外网站页面做多大博客导航wordpress
  • 具体阐述对网站如何加强建设全网营销课程
  • 多用户网站管理系统廊坊seo关键词排名
  • 免费建立自己的网站代码游乐场网站开发
  • 自学制作网站难不难雄安做网站优化的公司
  • 房地产广告设计网站做app网站公司
  • 做网站维护的是什么公司opencart网站
  • 广州天河建网站wordpress 登录空白页
  • 怎么建网站青州问枫家在深圳网页版
  • 如何做旅游网站的旅行家织梦猫html5高端网络服务机构网站模板
  • 公章在线制作网站做不了威海哪里可以建设企业网站
  • 装修10万元利润是多少网站seo方案案例
  • 破解wordpress网站密码wordpress 批量缩略图
  • 网站建设文化策划陕西网络公司网站建设
  • 深圳网站设计九曲网站建设科技创新小发明
  • 汕头网站设计价格网站建设私活
  • 南京专门做网站会员播放系统插件wordpress
  • 接单子做网站德州网站建设公司
  • 淄博网站制作优化科技网站制作公司
  • 怎样清理网站后门西宁网站建设王道下拉惠
  • 软件网站开发团队名称网站开发培训实训
  • 乐清建网站公司哪家好电商网站建设行情
  • 英语网站新增两个栏目wordpress伪静
  • 做门户网站广告沈阳网站优化排名
  • 网站建设推广价格手机百度如何发布作品