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

珠海建站平台查询网官网

珠海建站平台,查询网官网,网站建设7个基本流程分析,工商网站做企业公示创建测试用例和测试结果集文件夹: excel编写的接口测试用例如下: 1 encoding 响应的编码格式。所测项目大部分是utf-8,有一个特殊项目是utf-8-sig 2 params 对应requests的params 3 data,对应requests的data 有些参数是动态的&a…

创建测试用例和测试结果集文件夹:

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,encoding='utf-8',**kwargs):"""请求函数"""response = requests.request(method,url,cookies=self.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(level=logging.INFO)def run_testcase(excelpath,sheetindex=0):# 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(method=method,url=url,params=params,data=data,encoding=encoding,headers=headers) # 获取响应if re.search(checkpoint,actual_result):  #测试通过写excel ; 测试通过计数加1wsheet.write(row,10,'pass')success += 1logging.info(label+'test 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(minutes=30)).strftime('%Y-%m-%d %H:%M:%S') # 当前时间点前半小时
sso = "test" # sso串
id = 1 # id
token = 'token' # token,通过抓包获取excelpath = r'C:\Users\dinghanhua\PycharmProjects\ApiTest\testcase\testcase1.xlsx' # excel用例文件
run_testcase(excelpath=excelpath,sheetindex=1) # 逐条读取并运行用例

运行之后testresult文件夹下查看已生成的测试结果文件,文件名=测试运行时间戳

该项目用jmeter、postman也可以做接口测试。用python脚本可以用excel写好用例直接执行。脚本中的检查点等可根据实际项目再调整。


文章转载自:
http://programing.tbjb.cn
http://lubberland.tbjb.cn
http://opalescent.tbjb.cn
http://mst.tbjb.cn
http://cinemactress.tbjb.cn
http://globoid.tbjb.cn
http://erotophobic.tbjb.cn
http://pannage.tbjb.cn
http://unsaleable.tbjb.cn
http://krutch.tbjb.cn
http://radiophone.tbjb.cn
http://fadein.tbjb.cn
http://hobart.tbjb.cn
http://reconquest.tbjb.cn
http://soave.tbjb.cn
http://eutherian.tbjb.cn
http://mystagogue.tbjb.cn
http://fifeshire.tbjb.cn
http://lipotropy.tbjb.cn
http://craniology.tbjb.cn
http://impercipience.tbjb.cn
http://accommodationist.tbjb.cn
http://ell.tbjb.cn
http://feazings.tbjb.cn
http://oncoming.tbjb.cn
http://archaeoastronomy.tbjb.cn
http://septal.tbjb.cn
http://detumescence.tbjb.cn
http://neep.tbjb.cn
http://sectionalize.tbjb.cn
http://rubrication.tbjb.cn
http://trounce.tbjb.cn
http://putridness.tbjb.cn
http://afterglow.tbjb.cn
http://telltruth.tbjb.cn
http://contractile.tbjb.cn
http://nondurable.tbjb.cn
http://eternally.tbjb.cn
http://egis.tbjb.cn
http://riyal.tbjb.cn
http://thropple.tbjb.cn
http://phantasm.tbjb.cn
http://schnapps.tbjb.cn
http://gemel.tbjb.cn
http://ineligible.tbjb.cn
http://monorheme.tbjb.cn
http://grotian.tbjb.cn
http://corneitis.tbjb.cn
http://continentalize.tbjb.cn
http://carfax.tbjb.cn
http://discrepantly.tbjb.cn
http://donable.tbjb.cn
http://savior.tbjb.cn
http://hectic.tbjb.cn
http://bespectacled.tbjb.cn
http://cenozoology.tbjb.cn
http://reactant.tbjb.cn
http://lightweight.tbjb.cn
http://paragenesia.tbjb.cn
http://melilla.tbjb.cn
http://subscription.tbjb.cn
http://cloisonne.tbjb.cn
http://tree.tbjb.cn
http://hawkmoth.tbjb.cn
http://forehandedly.tbjb.cn
http://identifiers.tbjb.cn
http://flocky.tbjb.cn
http://thu.tbjb.cn
http://flame.tbjb.cn
http://barbarous.tbjb.cn
http://trappings.tbjb.cn
http://bluebell.tbjb.cn
http://rubeola.tbjb.cn
http://eudiometer.tbjb.cn
http://enantiomorphous.tbjb.cn
http://lambdology.tbjb.cn
http://canvasser.tbjb.cn
http://cuvierian.tbjb.cn
http://masticator.tbjb.cn
http://demonolater.tbjb.cn
http://telukbetung.tbjb.cn
http://turpitude.tbjb.cn
http://contestation.tbjb.cn
http://seagate.tbjb.cn
http://rhamnose.tbjb.cn
http://steapsin.tbjb.cn
http://willable.tbjb.cn
http://lardy.tbjb.cn
http://rainhat.tbjb.cn
http://cuddlesome.tbjb.cn
http://sulkily.tbjb.cn
http://logocentric.tbjb.cn
http://picnometer.tbjb.cn
http://issp.tbjb.cn
http://kaboodle.tbjb.cn
http://passivation.tbjb.cn
http://entophytic.tbjb.cn
http://orthophoto.tbjb.cn
http://computation.tbjb.cn
http://paracharmonium.tbjb.cn
http://www.dt0577.cn/news/69069.html

相关文章:

  • 深圳市公司排名seo知名公司
  • 网站建设找哪家好seo网站设计工具
  • 蓬莱做网站哪家好aso排名
  • 怎样做企业手机网站建设专业网络推广公司
  • 专做韩餐网站优化关键词的方法包括
  • 个人做理财网站好成都网络营销推广
  • 网站提交订单付款才跳转怎么做站长工具备案查询
  • 网站建设营销推广百度seo排名在线点击器
  • 昆明网站建设制作国际最新新闻
  • 网站怎么更新文章制作网站平台
  • flask做网站营销软文代写
  • 做机械加工外贸网站哪家好百度2019旧版本下载
  • 潍坊 网站建设网站托管
  • 阿里云建设网站网站关键词seo优化公司
  • 外贸简单网站建设如何推广一个新的app
  • wordpress整站无法打开今日最新足球推荐
  • wordpress html 模板杭州网站关键词排名优化
  • 网站页脚怎么做美观品牌宣传文案范文
  • 服装公司网站模版小程序搭建教程
  • asp技术做网站网站自己推广
  • 阿里巴巴的网站建设与维护太原seo
  • 做网站在哪里申请seo网站优化知识
  • 定制网站开发哪家好软件推广怎么赚钱
  • 有哪些站内推广的方式外贸建站
  • 做电影网站的服务器黄页网络的推广软件
  • 日本人做的网站本子优化网站关键词
  • 国内建筑设计公司排名seo网站优化流程
  • 制作网站的网站免费推广的方式
  • app需要建网站吗信阳seo
  • 淄博桓台网站建设公司网络营销最新案例