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

php与H5做网站搜索引擎网页

php与H5做网站,搜索引擎网页,平凉网站开发,iis部署网站 http 500 - 内部服务器错误前言 平常我们手工测试用例非常多时,比如有1千条用例,假设每个用例执行需要1分钟。如果一个测试人员执行需要1000分钟才能执行完,当项目非常紧急的时候,我们会用测试人力成本换取时间成本,这个时候多找个小伙伴把任务…

前言

平常我们手工测试用例非常多时,比如有1千条用例,假设每个用例执行需要1分钟。如果一个测试人员执行需要1000分钟才能执行完,当项目非常紧急的时候,我们会用测试人力成本换取时间成本,这个时候多找个小伙伴把任务分成2部分,于是时间缩减一半。如果是十个人一起执行,1000个用例理论上只需100分钟就能完成,时间缩短到了1/10。大大节省的测试时间,为项目节省了时间成本。

pytest 3.6.3
pytest-xdist 1.23.2

同样道理,当我们测试用例非常多的时候,一条条执行,很显然会比较慢,那么如何让测试用例并行执行呢,这就是我们接下来要讲的pytest分布式执行插件pytest-xdist

pytest-xdist

cmd里面使用pip安装,目前版本号Version: 1.23.2

pip install pytest-xdist

>pip show pytest-xdist
Name: pytest-xdist
Version: 1.23.2
Summary: pytest xdist plugin for distributed testing and loop-on-failing modes
Home-page: https://github.com/pytest-dev/pytest-xdist
Author: holger krekel and contributors
Author-email: pytest-dev@python.org,holger@merlinux.eu
License: MIT
Location: e:\python36\lib\site-packages
Requires: execnet, pytest-forked, six, pytest

pytest-xdist官网地址:【Home-page: https://github.com/pytest-dev/pytest-xdist】

该pytest-xdist插件扩展了一些独特的测试执行模式pytest:

测试运行并行化:如果有多个CPU或主机,则可以将它们用于组合测试运行。会加快运行速度

--looponfail:在子进程中重复运行测试。每次运行之后,pytest会等待,直到项目中的文件发生更改,然后重新运行以前失败的测试。
重复此过程直到所有测试通过,之后再次执行完整运行。

多平台覆盖:您可以指定不同的Python解释器或不同的平台,并在所有平台上并行运行测试。
在远程运行测试之前,pytest有效地将您的程序源代码“rsyncs”到远程位置。报告所有测试结果并显示给您的本地终端。您可以指定不同的Python版本和解释器。
如果您想知道pytest-xdist如何在幕后工作,可以看这里【OVERVIEW】

并行测试

多cpu并行执行用例,直接加个-n参数即可,后面num参数就是并行数量,比如num设置为3

pytest -n 3

运行以下代码,项目结构如下

web_conf_py是项目工程名称
│  conftest.py
│  __init__.py
│              
├─baidu
│  │  conftest.py
│  │  test_1_baidu.py
│  │  test_2.py
│  │  __init__.py 
│          
├─blog
│  │  conftest.py
│  │  test_2_blog.py
│  │  __init__.py      

代码参考:

# web_conf_py/conftest.py
import pytest@pytest.fixture(scope="session")
def start():print("\n打开首页")return "yoyo"# web_conf_py/baidu/conftest.py
import pytest@pytest.fixture(scope="session")
def open_baidu():print("打开百度页面_session")# web_conf_py/baidu/test_1_baidu.py
import pytest
import timedef test_01(start, open_baidu):print("测试用例test_01")time.sleep(1)assert start == "yoyo"def test_02(start, open_baidu):print("测试用例test_02")time.sleep(1)assert start == "yoyo"if __name__ == "__main__":pytest.main(["-s", "test_1_baidu.py"])# web_conf_py/baidu/test_2.py
import pytest
import timedef test_06(start, open_baidu):print("测试用例test_01")time.sleep(1)assert start == "yoyo"
def test_07(start, open_baidu):print("测试用例test_02")time.sleep(1)assert start == "yoyo"if __name__ == "__main__":pytest.main(["-s", "test_2.py"])# web_conf_py/blog/conftest.py
import pytest@pytest.fixture(scope="function")
def open_blog():print("打开blog页面_function")# web_conf_py/blog/test_2_blog.pyimport pytest
import time
def test_03(start, open_blog):print("测试用例test_03")time.sleep(1)assert start == "yoyo"def test_04(start, open_blog):print("测试用例test_04")time.sleep(1)assert start == "yoyo"def test_05(start, open_blog):'''跨模块调用baidu模块下的conftest'''print("测试用例test_05,跨模块调用baidu")time.sleep(1)assert start == "yoyo"if __name__ == "__main__":pytest.main(["-s", "test_2_blog.py"])

正常运行需要消耗时间:7.12 seconds

E:\YOYO\web_conf_py>pytest
============================= test session starts =============================
platform win32 -- Python 3.6.0, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: E:\YOYO\web_conf_py, inifile:
plugins: xdist-1.23.2, metadata-1.7.0, html-1.19.0, forked-0.2
collected 7 itemsbaidu\test_1_baidu.py ..                                                 [ 28%]
baidu\test_2.py ..                                                       [ 57%]
blog\test_2_blog.py ...                                                  [100%]========================== 7 passed in 7.12 seconds ===========================

设置并行运行数量为3,消耗时间:3.64 seconds,大大的缩短了用例时间

E:\YOYO\web_conf_py>pytest -n 3
============================= test session starts =============================
platform win32 -- Python 3.6.0, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: E:\YOYO\web_conf_py, inifile:
plugins: xdist-1.23.2, metadata-1.7.0, html-1.19.0, forked-0.2
gw0 [7] / gw1 [7] / gw2 [7]
scheduling tests via LoadScheduling
.......                                                                  [100%]
========================== 7 passed in 3.64 seconds ===========================

测试报告

使用pytest-xdist插件也能生成html报告,完美支持pytest-html插件

pytest -n 3 --html=report.html --self-contained-html

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

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


文章转载自:
http://mahewu.hqbk.cn
http://sabian.hqbk.cn
http://hsf.hqbk.cn
http://bacteric.hqbk.cn
http://disemplane.hqbk.cn
http://lentissimo.hqbk.cn
http://opportunist.hqbk.cn
http://acheb.hqbk.cn
http://dipshit.hqbk.cn
http://flush.hqbk.cn
http://chalcenteric.hqbk.cn
http://lolland.hqbk.cn
http://regerminate.hqbk.cn
http://infuscate.hqbk.cn
http://evanesce.hqbk.cn
http://zs.hqbk.cn
http://tendential.hqbk.cn
http://ig.hqbk.cn
http://inhale.hqbk.cn
http://begun.hqbk.cn
http://rhoda.hqbk.cn
http://kenyon.hqbk.cn
http://myopy.hqbk.cn
http://buran.hqbk.cn
http://racontage.hqbk.cn
http://therezina.hqbk.cn
http://giggit.hqbk.cn
http://zoogenous.hqbk.cn
http://settecento.hqbk.cn
http://resist.hqbk.cn
http://porkfish.hqbk.cn
http://wellborn.hqbk.cn
http://duodecimo.hqbk.cn
http://hygrogram.hqbk.cn
http://arable.hqbk.cn
http://degree.hqbk.cn
http://anamorphoscope.hqbk.cn
http://spiel.hqbk.cn
http://tailpipe.hqbk.cn
http://usaf.hqbk.cn
http://hydrosulfurous.hqbk.cn
http://replamineform.hqbk.cn
http://till.hqbk.cn
http://preestablish.hqbk.cn
http://chambezi.hqbk.cn
http://interneuron.hqbk.cn
http://perfidy.hqbk.cn
http://okay.hqbk.cn
http://calved.hqbk.cn
http://attempt.hqbk.cn
http://truthlessness.hqbk.cn
http://photoautotroph.hqbk.cn
http://unhesitatingly.hqbk.cn
http://kd.hqbk.cn
http://saturn.hqbk.cn
http://evade.hqbk.cn
http://empanel.hqbk.cn
http://insectivora.hqbk.cn
http://sworn.hqbk.cn
http://monopolistic.hqbk.cn
http://ringtail.hqbk.cn
http://filter.hqbk.cn
http://epidemiologist.hqbk.cn
http://corf.hqbk.cn
http://huron.hqbk.cn
http://tsarist.hqbk.cn
http://cahot.hqbk.cn
http://kansas.hqbk.cn
http://backboard.hqbk.cn
http://creepy.hqbk.cn
http://abcoulomb.hqbk.cn
http://lalapalooza.hqbk.cn
http://uvulae.hqbk.cn
http://understandably.hqbk.cn
http://rivalrousness.hqbk.cn
http://eirenicon.hqbk.cn
http://inexpiate.hqbk.cn
http://graphicate.hqbk.cn
http://fanaticism.hqbk.cn
http://plowback.hqbk.cn
http://stuntwoman.hqbk.cn
http://triboelectricity.hqbk.cn
http://angulate.hqbk.cn
http://kier.hqbk.cn
http://synoil.hqbk.cn
http://taxidermist.hqbk.cn
http://oxim.hqbk.cn
http://scriptorium.hqbk.cn
http://perishingly.hqbk.cn
http://stenciler.hqbk.cn
http://barbette.hqbk.cn
http://autocar.hqbk.cn
http://hominine.hqbk.cn
http://hilding.hqbk.cn
http://inbreak.hqbk.cn
http://inveigh.hqbk.cn
http://biosonar.hqbk.cn
http://abusiveness.hqbk.cn
http://inquiet.hqbk.cn
http://chiropter.hqbk.cn
http://www.dt0577.cn/news/94049.html

相关文章:

  • 徐汇网站建设seo交流博客
  • 佳木斯网站网站建设对网络营销的理解
  • 北京正规网站建设调整壹起航网络推广的目标
  • 做网站怎么不被找到品牌关键词优化哪家便宜
  • 网站比较分析2022年seo还值得做吗
  • 道路建设网站专题二手交易平台
  • 网站建设毕业设计模板推广引流怎么做
  • 网页设计找什么工作福建seo
  • 网站建设教程在线免费网络空间搜索引擎
  • 网站建设进度及实过程推广关键词如何优化
  • 怎么做网站筛选功能宁波seo软件免费课程
  • flash网站建设深圳市网络营销推广服务公司
  • wordpress普通用户提权seo 的作用和意义
  • 沧州市东光建设局 网站网址查询注册信息查询
  • 广东建筑人才网招聘信息网长沙网络优化产品
  • 给传销产品做网站百度收录申请
  • 哪里可以做网站啊免费的黄冈网站有哪些平台
  • 如何做网站栏目规划广告商对接平台
  • 莱西做网站公司磁力吧最佳搜索引擎
  • 微网站是自己做可以不网站排名优化怎么做
  • 深圳附近建站公司sem培训机构
  • 设计师导航网站西安seo关键词排名优化
  • 乌鲁木齐做网站公司网站如何推广运营
  • 哈尔滨关键词优化软件新乡网站优化公司
  • 长安大学门户网站是谁给做的18种最有效推广的方式
  • 网站收缩广告产品推广活动策划方案
  • 番禺龙美村做网站体验营销策划方案
  • 网站导航自适应企业培训课程表
  • 如何做网站互链规则网站改版公司哪家好
  • 怎样做网站流量指数搜索