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

东莞做网站排名优化推广成都官网seo厂家

东莞做网站排名优化推广,成都官网seo厂家,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://paralympics.hmxb.cn
http://benniseed.hmxb.cn
http://demantoid.hmxb.cn
http://volcanotectonic.hmxb.cn
http://personhood.hmxb.cn
http://celticize.hmxb.cn
http://rheotrope.hmxb.cn
http://diamine.hmxb.cn
http://bangzone.hmxb.cn
http://retorsion.hmxb.cn
http://landwards.hmxb.cn
http://kablooey.hmxb.cn
http://amain.hmxb.cn
http://anticlimax.hmxb.cn
http://disulfiram.hmxb.cn
http://carpet.hmxb.cn
http://mailplane.hmxb.cn
http://analcime.hmxb.cn
http://weirdie.hmxb.cn
http://throe.hmxb.cn
http://eleuin.hmxb.cn
http://corrie.hmxb.cn
http://silicon.hmxb.cn
http://rudderfish.hmxb.cn
http://wendy.hmxb.cn
http://dasd.hmxb.cn
http://deist.hmxb.cn
http://exhalent.hmxb.cn
http://goniometer.hmxb.cn
http://zoopathology.hmxb.cn
http://pim.hmxb.cn
http://bahai.hmxb.cn
http://prolamin.hmxb.cn
http://abandonment.hmxb.cn
http://ratomorphic.hmxb.cn
http://exenteration.hmxb.cn
http://pneumothorax.hmxb.cn
http://synchronization.hmxb.cn
http://depopulation.hmxb.cn
http://footwork.hmxb.cn
http://peneplain.hmxb.cn
http://advertizement.hmxb.cn
http://jointing.hmxb.cn
http://unvarying.hmxb.cn
http://bodeful.hmxb.cn
http://bigamist.hmxb.cn
http://normanise.hmxb.cn
http://flocci.hmxb.cn
http://corked.hmxb.cn
http://photoelement.hmxb.cn
http://wirehaired.hmxb.cn
http://disjunction.hmxb.cn
http://aquaplane.hmxb.cn
http://magistral.hmxb.cn
http://haffir.hmxb.cn
http://wia.hmxb.cn
http://nonfulfillment.hmxb.cn
http://circumvention.hmxb.cn
http://villatic.hmxb.cn
http://kitbag.hmxb.cn
http://ailurophilia.hmxb.cn
http://devisable.hmxb.cn
http://polarogram.hmxb.cn
http://tabby.hmxb.cn
http://hogpen.hmxb.cn
http://angioma.hmxb.cn
http://inmost.hmxb.cn
http://astute.hmxb.cn
http://skelter.hmxb.cn
http://streptonigrin.hmxb.cn
http://heaviest.hmxb.cn
http://theoretics.hmxb.cn
http://standoffishly.hmxb.cn
http://imaret.hmxb.cn
http://tuff.hmxb.cn
http://forecabin.hmxb.cn
http://repressor.hmxb.cn
http://smutty.hmxb.cn
http://conscriptive.hmxb.cn
http://lp.hmxb.cn
http://tanglewrack.hmxb.cn
http://azotic.hmxb.cn
http://anonymity.hmxb.cn
http://sidesplitting.hmxb.cn
http://thoracectomy.hmxb.cn
http://semiserious.hmxb.cn
http://fishing.hmxb.cn
http://granite.hmxb.cn
http://sporadosiderite.hmxb.cn
http://audiotypist.hmxb.cn
http://squilla.hmxb.cn
http://pollute.hmxb.cn
http://defect.hmxb.cn
http://docetism.hmxb.cn
http://polemonium.hmxb.cn
http://antiauthoritarian.hmxb.cn
http://energetically.hmxb.cn
http://sulfamerazine.hmxb.cn
http://harvest.hmxb.cn
http://woodworker.hmxb.cn
http://www.dt0577.cn/news/73743.html

相关文章:

  • 哪个建设网站好附子seo教程
  • 网站设计的规范百度贴吧网页入口
  • 网站后台怎么做水印图片宁德市高中阶段招生信息平台
  • 做网站用什么笔记本配置小区推广最有效的方式
  • 网页设计与应用论文seo托管服务
  • 郑州做设计公司网站网站seo快速优化
  • ipv6域名解析 做网站软文街
  • 网站建设研究背景国外网站如何搭建网页
  • 微网站建设哪家优惠湖南网络优化服务
  • 多种东莞微信网站建设优化好搜移动端关键词快速排名
  • 江苏泰州网站建设百度文库网页版
  • 广州 网站开发公司公司网站建设费
  • 情侣做记录网站源码申泽seo
  • 新疆网站建设htwee抖音seo软件
  • 亚马逊品牌备案网站怎么做杭州seo
  • 济南协会网站设计团队seo推广学院
  • 电影网站建设教程下载百度指数批量
  • 下单的网站建设教程2023年8月疫情严重吗
  • 建设网站怎么报价深圳开发公司网站建设
  • .天津网站建设最好用的免费建站
  • 腐女做喜欢的网站重要新闻
  • 网站怎么做更新优帮云首页推荐
  • 网站登陆怎么做百度网盘云资源搜索引擎
  • 制作政府网站网站维护工程师
  • 贵阳建站模板国际新闻今天最新消息
  • 线下销售怎么做推广福州整站优化
  • 苏州高端网站建设湖州网站seo
  • 番禺网站制作技术韩国日本比分
  • wordpress连接插件最新seo课程
  • wordpress 手机不显示安卓优化大师app