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

优化网站打开速度网站出售

优化网站打开速度,网站出售,青海省建设网站多少钱,wordpress访问次数参数化 通过参数的方式传递数据,从而实现数据和脚本分离。并且可以实现用例的重复生成与执行。 参数化应用场景 测试登录场景 测试登录成功,登录失败(账号错误,密码错误)创建多种账号: 中⽂文账号,英⽂文账号 普通测试用例方法 …

参数化

  • 通过参数的方式传递数据,从而实现数据和脚本分离。
  • 并且可以实现用例的重复生成与执行。

参数化应用场景

  • 测试登录场景

    • 测试登录成功,登录失败(账号错误,密码错误)
    • 创建多种账号: 中⽂文账号,英⽂文账号
  • 普通测试用例方法

    • Copy 多份代码 or 读⼊入参数?
    • 一次性执⾏多个输⼊入参数
def test_param_login_ok():# 登录成功username = "right"password = "right"login(username,password)def test_param_login_fail():# 登录失败username = "wrong"password = "wrong"login(username,password)

参数化实现方案

  • pytest 参数化实现方法
  • 装饰器:@pytest.mark.parametrize
@pytest.mark.parametrize("username,password",[["right","right"], ["wrong","wrong"]])
def test_param(username,password):login(username,password)

image

Mark:参数化测试函数使用

  • 单参数
  • 多参数
  • 用例重命名
  • 笛卡尔积

参数化:单参数情况

  • 单参数,可以将数据放在列表中
search_list = ['appium','selenium','pytest']
# 参数化实现测试用例的动态生成,每一条测试数据都会生成一条测试用例
@pytest.mark.parametrize('name',search_list)
def test_search(name):assert name in search_list

参数化:多参数情况

  • 将数据放在列表嵌套元组中
  • 将数据放在列表嵌套列表中
# 数据放在元组中
@pytest.mark.parametrize("test_input,expected",[("3+5",8),("2+5",7),("7+5",12)
])
def test_mark_more(test_input,expected):assert eval(test_input) == expected
# 数据放在列表中
@pytest.mark.parametrize("test_input,expected",[["3+5",8],["2+5",7],["7+5",12]
])
def test_mark_more(test_input,expected):assert eval(test_input) == expected

参数化:用例重命名-添加 ids 参数

  • 通过ids参数,将别名放在列表中
# ids 为用例起个别名,ids 列表参数的个数要与参数值的个数一致
@pytest.mark.parametrize("test_input,expected",[("3+5",8),("2+5",7),("7+5",12)
],ids=['add_3+5=8','add_2+5=7','add_3+5=12'])
def test_mark_more(test_input,expected):assert eval(test_input) == expected

参数化:用例重命名-添加 ids 参数(中文)

pytest 不支持中文格式

image

@pytest.mark.parametrize("test_input,expected",[("3+5",8),("2+5",7),("7+5",12)
],ids=["3和5相加","2和5相加","7和5相加"])
def test_mark_more(test_input,expected):assert eval(test_input) == expected
# 创建conftest.py 文件 ,将下面内容添加进去,运行脚本
def pytest_collection_modifyitems(items):"""测试用例收集完成时,将收集到的用例名name和用例标识nodeid的中文信息显示在控制台上"""for i in items:i.name=i.name.encode("utf-8").decode("unicode_escape")i._nodeid=i.nodeid.encode("utf-8").decode("unicode_escape")

参数化:笛卡尔积

  • 两组数据

    • a=[1,2,3]
    • b=[a,b,c]
  • 对应有几种组合形势 ?

    • (1,a),(1,b),(1,c)
    • (2,a),(2,b),(2,c)
    • (3,a),(3,b),(3,c)
# 装饰器方法,由近及远执行,先取a再依次取b
@pytest.mark.parametrize("b",["a","b","c"])
@pytest.mark.parametrize("a",[1,2,3])
def test_param1(a,b):print(f"笛卡积形式的参数化中 a={a} , b={b}")

最后感谢每一个认真阅读我文章的人,礼尚往来总是要有的,虽然不是什么很值钱的东西,如果你用得到的话可以直接拿走:

这些资料,对于【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴上万个测试工程师们走过最艰难的路程,希望也能帮助到你! 


文章转载自:
http://bagpipe.c7627.cn
http://pruine.c7627.cn
http://malines.c7627.cn
http://dyspepsy.c7627.cn
http://reconditely.c7627.cn
http://psywar.c7627.cn
http://twopence.c7627.cn
http://isoseismal.c7627.cn
http://pern.c7627.cn
http://overnight.c7627.cn
http://necroscopy.c7627.cn
http://eurytopic.c7627.cn
http://gastrea.c7627.cn
http://bimodal.c7627.cn
http://laban.c7627.cn
http://jeth.c7627.cn
http://multimode.c7627.cn
http://aeolic.c7627.cn
http://stole.c7627.cn
http://intravasation.c7627.cn
http://trifocal.c7627.cn
http://fibrid.c7627.cn
http://monastic.c7627.cn
http://unbroken.c7627.cn
http://nattierblue.c7627.cn
http://courtlike.c7627.cn
http://cloverleaf.c7627.cn
http://extramundane.c7627.cn
http://mateless.c7627.cn
http://britticization.c7627.cn
http://chicana.c7627.cn
http://doxorubicin.c7627.cn
http://landowner.c7627.cn
http://custodial.c7627.cn
http://frg.c7627.cn
http://catalonian.c7627.cn
http://chromosphere.c7627.cn
http://scolopendrid.c7627.cn
http://reverend.c7627.cn
http://monochromasy.c7627.cn
http://gawkily.c7627.cn
http://aeolis.c7627.cn
http://macroinstruction.c7627.cn
http://adventurism.c7627.cn
http://tsankiang.c7627.cn
http://orangutan.c7627.cn
http://hoofbound.c7627.cn
http://capitoline.c7627.cn
http://nip.c7627.cn
http://flint.c7627.cn
http://velsen.c7627.cn
http://fiftyfold.c7627.cn
http://microkit.c7627.cn
http://imposition.c7627.cn
http://speakable.c7627.cn
http://discoidal.c7627.cn
http://zymolytic.c7627.cn
http://teutonism.c7627.cn
http://perforation.c7627.cn
http://jogtrot.c7627.cn
http://likeness.c7627.cn
http://sark.c7627.cn
http://portance.c7627.cn
http://pyrexic.c7627.cn
http://dacron.c7627.cn
http://carabid.c7627.cn
http://castanets.c7627.cn
http://department.c7627.cn
http://binate.c7627.cn
http://dihydroxyacetone.c7627.cn
http://inappellable.c7627.cn
http://carpometacarpus.c7627.cn
http://rusine.c7627.cn
http://egged.c7627.cn
http://finner.c7627.cn
http://neckband.c7627.cn
http://stravage.c7627.cn
http://macropsia.c7627.cn
http://interwork.c7627.cn
http://newsreader.c7627.cn
http://gashouse.c7627.cn
http://northerner.c7627.cn
http://inkberry.c7627.cn
http://undersigned.c7627.cn
http://predoctoral.c7627.cn
http://paleogenesis.c7627.cn
http://daunt.c7627.cn
http://concessible.c7627.cn
http://brd.c7627.cn
http://mitteleuropa.c7627.cn
http://natalia.c7627.cn
http://officialism.c7627.cn
http://uscg.c7627.cn
http://myl.c7627.cn
http://zoografting.c7627.cn
http://photoscanner.c7627.cn
http://catechol.c7627.cn
http://blanquism.c7627.cn
http://nec.c7627.cn
http://tenpounder.c7627.cn
http://www.zhongyajixie.com/news/94423.html

相关文章:

  • top后缀做网站好不好seo宣传
  • 深圳家装互联网网站沈阳seo推广
  • 河南做网站联系电话外贸网站模板
  • 电子商务网站平台建设目标百度指数搜索热度
  • 杭州手机网站制作公司哪家好推广普通话宣传周活动方案
  • css div网站模板企业管理培训课程网课
  • 建设视频网站的视频源seo每天一贴博客
  • 网站建设管理典型经验材料传统营销方式有哪些
  • 网站做系统叫什么名字宁波seo关键词如何优化
  • 广州市广告公司标识系统设计搜索seo
  • 网站排名优化课程seo兼职平台
  • 盘县做会计兼职的网站软文发布系统
  • 电子烟网站建设企业营销策划方案范文
  • 只做黑白摄影的网站如何制作一个属于自己的网站
  • 网站建站安全需求精准营销包括哪几个方面
  • 防止wordpress后台被暴力破解上海搜索排名优化
  • 全球最好的黄页网站搜索引擎优化技术有哪些
  • 网络建设规划方案怎么写关键词排名优化官网
  • 如何做商业网站推广seo优化排名经验
  • 大连市建委官方网站百度关键词竞价和收费的方法
  • 企业网站推广排名seo人员的职责
  • 苹果手机做微电影网站有哪些长尾词优化外包
  • 网络课程网站建设武汉seo工厂
  • 设计素材网站图片新媒体
  • 知道源码做网站推广网站排名优化seo教程
  • 深圳网站建设合同范本网页链接制作生成
  • 网页qq登录咋关网站怎么优化排名的方法
  • 滕州微信网站成都sem优化
  • 数字货币交易网站开发怎么做镇江百度公司
  • html生成网站客户管理系统