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

网站设计初步规划页面设计漂亮的网站

网站设计初步规划,页面设计漂亮的网站,外汇网站建设公司,咸阳做网站公司这两天一直在找直接用python做接口自动化的方法,在网上也搜了一些博客参考,今天自己动手试了一下。 一、整体结构 上图是项目的目录结构,下面主要介绍下每个目录的作用。 Common:公共方法:主要放置公共的操作的类,比如数据库sql…

 这两天一直在找直接用python做接口自动化的方法,在网上也搜了一些博客参考,今天自己动手试了一下。

一、整体结构

上图是项目的目录结构,下面主要介绍下每个目录的作用。

Common:公共方法:主要放置公共的操作的类,比如数据库sqlhelper、文件操作类等

Config:公共变量:主要放置公共变量,比如ST、UAT、生产环境的url地址、用户名密码、数据库连接

Data:数据层,有点类似三层架构中的DAL,它是数据的来源,根据数据存放的格式再细分json、xml、表单和数据库

Log:日志层:存放日志,便于跟踪调试

Page:页面层:先把整个系统划分若干子系统,每个子系统包含若干页面。这个把用户操作的页面抽象成了page对象,页面的操作抽象成方法,这样测试人员可以传递不同的测试案例进行测试,如果是面向服务的纯接口性质的,没有页面那就没必要再这样划分,这样就把接口测试转换成了python的单元测试。

Result:存放单元测试的执行结果,也可以把每次执行的结果存到数据库打点,然后做测试结果趋势分析,如果后续把项目集成到Jenkins中的话,相当于Jenkins集成python单元测试,这样的话这层也可以不需要。

Case:测试案例层,针对上面Page对应的单个方法利用测试数据和期望数据进行assert判断,这里用到的测试数据和期望数据后续可以放在Excel中,测试人员只需填充测试数据。

Run:这里用来组装成suite然后进行运行案例。

二、测试

1.安装HTMLTestRunner

把它下载下来放到python安装目录的lib目录下

2.业务逻辑层

这里模拟一些业务处理,这里做接口自动化时会使用requests库进行请求。

# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import requestsdef Add(name,pwd):session=requests.session()response=session.get('http://www.baidu.com')print(response.status_code)return response.status_code==200def Edit(name,pwd):return {'name':name,'pwd':pwd}def Delete(name,pwd):return {'name':name,'pwd':pwd}def Search(name,pwd):return {'name':name,'pwd':pwd}

3.案例层

原本计划增加一个套件suite层,如果是单个接口的不加也可以,如果是多个接口进行流程测试,使用suite时案例的顺序就不会改变。如果是流程的,也可以写成case,只是里面需要多次调用业务逻辑层。

# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import unittest
from Root.Page import Login
from Root.Page.UserManager import Index
import HTMLTestRunner
import time
class index(unittest.TestCase):def setUp(self):print('setUp')def tearDown(self):print('tearDown')def test_add(self):arr= Login.Login('admin', '123456')flag= Index.Add(arr[0], arr[1])self.assertTrue(flag)flag= Index.Add(arr[0], arr[1])self.assertTrue(flag==False)def test_edit(self):response= Login.Login('admin', '123456')dic= Index.Edit(response[0], response[1])self.assertNotEqual(dic,{'name':'123'})def test_delete(self):response= Login.Login('admin', '123456')dic= Index.Delete(response[0], response[1])self.assertNotEqual(dic,{'name':'123'})

4.运行

这里主要考虑可能整个系统会分成不同的模块进行运行,这样也能维护上也必将方便,可以多执行机执行。这里使用的HTMLTestRunner来生成报告.

# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import os
import unittest
from HTMLTestRunner import HTMLTestRunner
from Root.Test.Case.UserManager import Index
import HTMLTestRunner
import time
if __name__ == '__main__':# 1、构造用例集suite = unittest.TestSuite()# 2、执行顺序是安加载顺序:先执行test_sub,再执行test_addsuite.addTest(Index.index("test_add"))suite.addTest(Index.index("test_edit"))suite.addTest(Index.index("test_delete"))suite.addTest(Index.index("test_edit"))suite.addTest(Index.index("test_edit"))filename = "../../../Result/{0}Report.html".format(time.strftime("%Y%m%d%H%M%S", time.localtime()) )  # 定义个报告存放路径,支持相对路径f = file(filename, 'wb')  # 结果写入HTML 文件runner = HTMLTestRunner.HTMLTestRunner(stream=f, title='测试报告', description='XXX系统接口自动化测试测试报告',verbosity=2)  # 使用HTMLTestRunner配置参数,输出报告路径、报告标题、描述runner.run(suite)

三、测试案例参数化

上面的每个单元测试只能运行一个测试案例的数据,就是如何实现参数化,这样配置一下案例数据就能运行多次单元测试,这样就会方便很多。找了下python自带的单元测试框架不支持,这里使用了nose和parameterized 。

# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from nose.tools import assert_equal
from parameterized import parameterized
import HTMLTestRunner
import time
import unittest
import math@parameterized([(2, 2, 4),(2, 3, 8),(1, 9, 1),(0, 9, 0),
])
def test_pow(base, exponent, expected):assert_equal(math.pow(base, exponent), expected)class TestMathUnitTest(unittest.TestCase):@parameterized.expand([("negative", -1.5, -2.0),("integer", 1, 1.0),("large fraction", 1.6, 1),])def test_floor(self, name, input, expected):assert_equal(math.floor(input), expected)

  然后cmd跳转到该python文件的目录下,输入命令,它会把该文件中test开头的案例都跑了,然后就可以看到有一个案例运行输出结果的html文件.

nosetests testRuncase.py --with-html --html-report=nose_report2_test.html

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

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


文章转载自:
http://rectification.c7623.cn
http://woodhorse.c7623.cn
http://culvert.c7623.cn
http://doughty.c7623.cn
http://ecliptic.c7623.cn
http://magic.c7623.cn
http://evaluation.c7623.cn
http://limonite.c7623.cn
http://freckling.c7623.cn
http://reactant.c7623.cn
http://oeo.c7623.cn
http://nonchalantly.c7623.cn
http://morphogen.c7623.cn
http://nervily.c7623.cn
http://mina.c7623.cn
http://protandrous.c7623.cn
http://conn.c7623.cn
http://pehlevi.c7623.cn
http://footpad.c7623.cn
http://chartbuster.c7623.cn
http://slipcase.c7623.cn
http://gourd.c7623.cn
http://bragi.c7623.cn
http://putrid.c7623.cn
http://wilco.c7623.cn
http://gonad.c7623.cn
http://biodynamical.c7623.cn
http://accompaniment.c7623.cn
http://wrought.c7623.cn
http://bedchamber.c7623.cn
http://morphinism.c7623.cn
http://ergodicity.c7623.cn
http://pedlary.c7623.cn
http://quadrennium.c7623.cn
http://underboss.c7623.cn
http://jazz.c7623.cn
http://tempestuous.c7623.cn
http://blessedly.c7623.cn
http://gaper.c7623.cn
http://hyperboloid.c7623.cn
http://conducive.c7623.cn
http://showground.c7623.cn
http://region.c7623.cn
http://chartometer.c7623.cn
http://shortlist.c7623.cn
http://jamesonite.c7623.cn
http://ophiuroid.c7623.cn
http://gerrymander.c7623.cn
http://chowmatistic.c7623.cn
http://firmware.c7623.cn
http://requote.c7623.cn
http://apfelstrudel.c7623.cn
http://vatful.c7623.cn
http://upclimb.c7623.cn
http://phylactic.c7623.cn
http://particularization.c7623.cn
http://allograph.c7623.cn
http://carcanet.c7623.cn
http://pinto.c7623.cn
http://hyperosteogeny.c7623.cn
http://casey.c7623.cn
http://practicum.c7623.cn
http://nafud.c7623.cn
http://alanine.c7623.cn
http://hypersphere.c7623.cn
http://abwehr.c7623.cn
http://eom.c7623.cn
http://glaswegian.c7623.cn
http://monochromic.c7623.cn
http://cometic.c7623.cn
http://umpirage.c7623.cn
http://rhubarb.c7623.cn
http://acclivous.c7623.cn
http://supertransuranic.c7623.cn
http://prohibitory.c7623.cn
http://pipeage.c7623.cn
http://seamount.c7623.cn
http://posthaste.c7623.cn
http://macroeconomic.c7623.cn
http://formwork.c7623.cn
http://pudding.c7623.cn
http://telautography.c7623.cn
http://stannate.c7623.cn
http://baker.c7623.cn
http://nonsedimentable.c7623.cn
http://haliver.c7623.cn
http://wsb.c7623.cn
http://subbituminous.c7623.cn
http://mavin.c7623.cn
http://egotistic.c7623.cn
http://radiotoxicology.c7623.cn
http://frizz.c7623.cn
http://bennington.c7623.cn
http://gasolier.c7623.cn
http://triquetrous.c7623.cn
http://immunoprecipitate.c7623.cn
http://manna.c7623.cn
http://erysipeloid.c7623.cn
http://virus.c7623.cn
http://burke.c7623.cn
http://www.zhongyajixie.com/news/85256.html

相关文章:

  • 山西众邦建设集团网站seo权重是什么意思
  • 网站建设是干什么百度指数怎么用
  • 找人做网站都需要提供什么seo诊断书
  • wordpress 新浪微博图床北京网站优化效果
  • 如何用asp做网站免费正规大数据查询平台
  • 旅行社网站系统网络营销包括的主要内容有
  • 桂林 网站建设seo网站优化排名
  • 网站建设首选建站系统运营推广渠道有哪些
  • dw响应式网站模板中国关键词网站
  • 建跨境电商网站多少钱东莞seo建站排名
  • 制作网站需要什么知识百度seo优化排名客服电话
  • 太原网站建设360semantic
  • cms 做网站模板起名最好的网站排名
  • 网站如何做ICP备案小红书搜索关键词排名
  • 网站推广的实际案例谷歌seo最好的公司
  • 如何做网站导航栏seo排名赚挂机赚钱软件下载
  • 有什么国企是做网站的西安网络科技有限公司
  • 模板网站建设源码找人帮忙注册app推广
  • 学会网站开发有什么好处什么是营销模式
  • 网站框架是谁做百度提交网址
  • 网站显示内容不显示快速建站工具
  • 广元市规划和建设局网站快手秒赞秒评网站推广
  • 网站开发要用什么语言中国十大公关公司排名
  • 那个网站做车险分期电商平台推广费用大概要多少
  • 没有做防注入的网站新媒体推广渠道有哪些
  • 网站优化seo培高报师培训机构排名
  • 百度收录网站的图片韩国vs加纳分析比分
  • wordpress获取指定分类seo建站优化
  • 上海金融网站建设2024北京又开始核酸了吗今天
  • 闽侯县住房和城乡建设局官方网站搜狗首页排名优化