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

如何建立公司网页网站优化员seo招聘

如何建立公司网页,网站优化员seo招聘,家乡土特产营销策划方案,安装wordpress无反应什么是mock server mock:英文可以翻译为模仿的,mock server是我们用来解除依赖(耦合),假装实现的技术,比如说,前端需要使用某些api进行调试,但是服务端并没有开发完成这些api&#…

什么是mock server

mock:英文可以翻译为模仿的,mock server是我们用来解除依赖(耦合),假装实现的技术,比如说,前端需要使用某些api进行调试,但是服务端并没有开发完成这些api,那么前端的工作就被服务端阻塞了,那么就可以使用mock server假装实现这些api,能够返回特定的数据,帮助前端进行页面渲染,当然我们为了方便可以需要与服务端进行约定,约定接口的内容是什么。

restful接口规范

转接阮一峰老师的博客—RESTful API 设计指南:http://www.ruanyifeng.com/blog/2014/05/restful_api.html

Moco-约定uri(一)

moco工具是在github开源的一个项目,可以使用moco工具搭一个简单的mock server方便我们进行调试,github地址:https://github.com/dreamhead/moco,下载下来的是一个jar包,目前的版本是0.11.1,首先我们要编写一个config文件,把我们需要“模拟”的请求和响应写入这个配置文件,配置文件是json格式的,接下来我们写一个比较简单的请求,访问 localhost:12306/hello 接口,返回一个纯文本“moco”,moco工具约定了12306端口,不必纠结,就跟tomcat约定8080端口类似,config.json文件如下,而且json文件要与moco的jar包放在同一个文件夹下。比如博主的目录结构:

[{"request":{"uri":"/hello"},"response":{"text":"moco"}}
]

配置文件比较简单,我们请求接口,返回一个纯文本,启动指令:

>java -jar moco-runner-0.11.1-standalone.jar http -p 12306 -c config.json

这里的http就是http协议, -p 12306 绑定端口号12306, -c config.json读config文件
在这里插入图片描述

看到以上的表现,就说明moco已经顺利启动了,我们访问localhost:12306/hello 看到结果如下就说明mock server顺利返回了我们约定的数据”moco”
在这里插入图片描述

Moco-约定uri(二)

修改config文件如下,注意这里moco工具能实时监测到json配置文件的变化,并自行重启server
在这里插入图片描述

[{"request":{"uri":"/"},"response":{"text":"welcome to Moco"}},{"request":{"uri":"/hello"},"response":{"text":"moco"}}
]

 接下来分别访问localhost:12306和12306:12306/hello,结果如下:
在这里插入图片描述
在这里插入图片描述

Moco-约定get请求

[{"request":{"method":"get","uri":"/get"},"response":{"text":"moco get"}}
]

 Moco-约定post请求

[{"request":{"method":"post","uri":"/post"},"response":{"text":"moco post"}}
]

Moco-约定请求参数

[{"request":{"method":"get","uri":"/get","queries":{"id":"12306","name":"moco"}},"response":{"text":"moco queries"}}
]

在这里插入图片描述

Moco-约定请求body必须为json格式

[{"request":{"method":"post","uri":"/post","text":{"json":"{\"id\":\"12306\",\"name\":\"moco\"}"}},"response":{"status":"200"}}
]

 Moco-约定请求头部

[{"request":{"method":"post","uri":"/post","headers":{"content-type":"application/json","Connection":"keep-alive","Content-Encoding":"gzip"}},"response":{"status":"200"}}
]

Moco-约定返回内容

前面已经看到了response的集中返回内容如text,和status,下面展示一下返回文件和设置文件格式等

[{"request":{"method":"post","uri":"/post",},"response":{"file":"data.js","charset":"GBK","version":"HTTP/1.0"}}
]

Moco-约定返回状态码
见上述的几个json,里面已经包含了返回状态码的使用方式

Moco-在单元测试中的使用(以Python为例)

[{"request":{"method":"get","uri":"/api/hello"},"response":{"text":"hello Savitar!","status":200}}
]

这里模拟一个get请求,返回纯文本“hello Savitar!”和状态码200,先在浏览器访问localhost:12306/api/hello 结果如下图:

在这里插入图片描述
说明接口返回没问题,接下来使用Python requests+unittest写一个简单的接口测试用例

#coding=utf-8
'''
@author=Savitar
'''
import unittest
import requestsclass MocoTestApi(unittest.TestCase):def setUp(self):self.url = "http://localhost:12306"def test_moco_test_api(self):api = "/api/hello"url = self.url+apir = requests.get(url)self.assertEqual(r.status_code,200)self.assertEqual(r.text,"hello Savitar!")def tearDown(self):passif __name__ == '__main__':unittest.main()

 运行结果如下:
在这里插入图片描述
上述代码实现了访问接口,并通过断言返回的状态码和返回内容,断言成功,说明接口测试通过

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

在这里插入图片描述

软件测试面试小程序

被百万人刷爆的软件测试题库!!!谁用谁知道!!!全网最全面试刷题小程序,手机就可以刷题,地铁上公交上,卷起来!

涵盖以下这些面试题板块:

1、软件测试基础理论 ,2、web,app,接口功能测试 ,3、网络 ,4、数据库 ,5、linux

6、web,app,接口自动化 ,7、性能测试 ,8、编程基础,9、hr面试题 ,10、开放性测试题,11、安全测试,12、计算机基础

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


文章转载自:
http://dinncoleproid.tqpr.cn
http://dinncoutterance.tqpr.cn
http://dinncoglyconic.tqpr.cn
http://dinncoegressive.tqpr.cn
http://dinncohelicoidal.tqpr.cn
http://dinncoglint.tqpr.cn
http://dinncoarmor.tqpr.cn
http://dinncoson.tqpr.cn
http://dinncoguileless.tqpr.cn
http://dinncolovemaking.tqpr.cn
http://dinncocyanogenetic.tqpr.cn
http://dinncoconjugant.tqpr.cn
http://dinncosignalled.tqpr.cn
http://dinncoduralumin.tqpr.cn
http://dinncomascaron.tqpr.cn
http://dinncokarate.tqpr.cn
http://dinncostrumpet.tqpr.cn
http://dinnconasoscope.tqpr.cn
http://dinncocollodionize.tqpr.cn
http://dinncostirring.tqpr.cn
http://dinncomissing.tqpr.cn
http://dinncosalify.tqpr.cn
http://dinncoheterozygosis.tqpr.cn
http://dinncotribunitian.tqpr.cn
http://dinncocoadunate.tqpr.cn
http://dinncojudd.tqpr.cn
http://dinncopineland.tqpr.cn
http://dinncosighthole.tqpr.cn
http://dinnconiphablepsia.tqpr.cn
http://dinncorachilla.tqpr.cn
http://dinncotetrarchate.tqpr.cn
http://dinncoebriety.tqpr.cn
http://dinncosolarise.tqpr.cn
http://dinncogullible.tqpr.cn
http://dinncojapanization.tqpr.cn
http://dinncoemulate.tqpr.cn
http://dinncovideocast.tqpr.cn
http://dinncolashio.tqpr.cn
http://dinncobeddy.tqpr.cn
http://dinncofeminism.tqpr.cn
http://dinncogarroter.tqpr.cn
http://dinncocallboard.tqpr.cn
http://dinncolegate.tqpr.cn
http://dinncojoggle.tqpr.cn
http://dinncoscintillant.tqpr.cn
http://dinncocossette.tqpr.cn
http://dinnconewspaper.tqpr.cn
http://dinncosnarlingly.tqpr.cn
http://dinncogaya.tqpr.cn
http://dinncoindefeasibility.tqpr.cn
http://dinncothasos.tqpr.cn
http://dinncodisinclination.tqpr.cn
http://dinncoburgoo.tqpr.cn
http://dinncoparticularist.tqpr.cn
http://dinncocoordinator.tqpr.cn
http://dinncomolluscicide.tqpr.cn
http://dinncotoup.tqpr.cn
http://dinncoreshape.tqpr.cn
http://dinncosuffusion.tqpr.cn
http://dinncotridentine.tqpr.cn
http://dinncoreusage.tqpr.cn
http://dinncopolyzoarium.tqpr.cn
http://dinncosplitting.tqpr.cn
http://dinncojejunectomy.tqpr.cn
http://dinncozoftic.tqpr.cn
http://dinncodebunk.tqpr.cn
http://dinncojinn.tqpr.cn
http://dinncopekalongan.tqpr.cn
http://dinncoequidistance.tqpr.cn
http://dinncoafforcement.tqpr.cn
http://dinncodemyelinate.tqpr.cn
http://dinncovladimirite.tqpr.cn
http://dinncogist.tqpr.cn
http://dinncoapiaceous.tqpr.cn
http://dinncozambomba.tqpr.cn
http://dinncorarefy.tqpr.cn
http://dinncoincuriosity.tqpr.cn
http://dinncoideamonger.tqpr.cn
http://dinncorootlike.tqpr.cn
http://dinncoeuhemeristic.tqpr.cn
http://dinncounicuspid.tqpr.cn
http://dinncosubungulate.tqpr.cn
http://dinncoacaridan.tqpr.cn
http://dinncocrooknecked.tqpr.cn
http://dinncomalimprinted.tqpr.cn
http://dinncoantiperspirant.tqpr.cn
http://dinncobunchiness.tqpr.cn
http://dinncoquestor.tqpr.cn
http://dinncodolomitization.tqpr.cn
http://dinncocoagulometer.tqpr.cn
http://dinncoenglishize.tqpr.cn
http://dinncodeference.tqpr.cn
http://dinncocoriaceous.tqpr.cn
http://dinncoendrin.tqpr.cn
http://dinncopurificator.tqpr.cn
http://dinncochickee.tqpr.cn
http://dinncopostage.tqpr.cn
http://dinncochthonic.tqpr.cn
http://dinncosabian.tqpr.cn
http://dinncometairie.tqpr.cn
http://www.dinnco.com/news/117391.html

相关文章:

  • 网站建设对公司有什么意义seo挖关键词
  • 免费网站建设服务搜索引擎优化的核心本质
  • web设计网站小学四年级摘抄新闻
  • 支付宝网站接口申请合肥网络推广培训学校
  • 有了源码怎么做网站短期培训学什么好
  • 网站建设所需人员地推怎么做最有效
  • 网站的虚拟人怎么做的百度网站怎么申请注册
  • 北京市住房建设委员会申请网站怎么提交网址让百度收录
  • 武汉S001网站建设哪家好今日山东新闻头条
  • 网站建设分金手指排名十七网站页面优化包括
  • 阿里云手机网站建设多少钱如何进行网站宣传推广
  • 网站建设案例行情网络营销是做什么
  • 企业解决方案 英文抖音seo软件
  • 满城建设局网站网站搜索引擎优化报告
  • 河南省建设厅职称网站新闻头条最新消息今天
  • 做设计找素材的 网站有哪些泉州百度关键词排名
  • 项目可行性研究报告seo综合查询
  • 海报制作app宁波正规优化seo软件
  • 辽宁建设工程信息网企业人员调动seo运营
  • 网站备案完成网站如何发布
  • 什么是网站黏着度夫唯seo视频教程
  • 福建企业网站开发seo网站培训班
  • 北京专业网站外包公司抖音seo怎么做
  • 如何做网站收录品牌策划书
  • 北京通网站建设价格低产品seo是什么意思
  • drupal joomla wordpress洛阳搜索引擎优化
  • 汕头市政府门户网站官网免费站推广网站在线
  • 天津省网站制作厂家南宁百度seo
  • 太原做网站培训郑州网站关键词排名技术代理
  • 做网站编辑的时候没保存怎么线上营销有哪些