自动化测试框架Taffy

Taffy是基于nosetests的自动化测试框架

Taffy主要用来测试后台服务接口(包括且不限于Http, Dubbo/hessian, Webservice, Socket等类型),也可以集成Selinum, Appium进行Web或APP的自动化测试

Taffy封装实现了结果对比,配置读取,DB/Redis操作,数据加解密等接口

基本用法可以参考:test_demo.py

Github地址:https://github.com/lovesoo/Taffy

1. 运行环境

1) macOS,linux,windows

2) nose 1.3.7

3) python 2.7

2. 项目结构

1) config 配置文件

2) Tests 测试用例

3) Util 工具类

checkTool   -  比较方法及结果校验

commonTool  -  配置文件读取

DBTool  -  数据库操作(mysql,sqlserver)

hessianTool  -  hessian接口调用

httpTool  -  http接口调用

OATool  -  正交表设计测试用例

redisTool  -  redis操作(支持redis及redis cluster)

securityTool  -  数据加解密

seleniumTool  -  selenium PageObject对象封装

webserviceTool  -  webservice接口调用

3. 环境部署

3.1 Python

请下载安装Python2.7.x版本:https://www.python.org/downloads/

3.2 IDE

官网地址:http://www.jetbrains.com/pycharm/

下载安装完成后,注册时选择License server,输入:http://idea.imsxm.com 即可激活^^

3.3 安装第三方lib库

使用pip install可以安装大多数的lib库::

1
2
3
4
5
#可以单独安装lib库
pip install xxxlib
 
#也可以批量安装
pip install -r requirements.txt

Windows下,一些棘手的lib库安装方法:

1) mysql-python

首先安装Microsoft Visual C++ Compiler for Python 2.7:http://aka.ms/vcpython27

然后下载msi包安装:https://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/

2) pymssql

可直接下载exe包安装: https://pypi.python.org/pypi/pymssql/2.1.1#downloads

python2.7+32位windows系统,请选择:pymssql-2.1.1.win32-py2.7.exe (md5)

3) pyhessian

Github地址:https://github.com/theatlantic/python-hessian

下载zip包,解压后进行文件夹内,运行如下命令安装:

1
python setup.py install

4) webdriver

这里只说下chromedriver的下载配置方法:

下载地址:https://sites.google.com/a/chromium.org/chromedriver/downloads

下载chromedriver_win32.zip,解压后将chromedriver.exe放到Python安装路径下(如C:\Python27\)

4. 使用方法

4.1 Pycharm配置

1)「File」–>「open」,打开下载的项目taffy

2)「Run」–>「Edit Configurations」–>「Defaults」->「Python」,配置Python interpreter为当前python版本安装目录

3)「Run」–>「Edit Configurations」–>「Defaults」->「Python tests」–>「Nosetests」,Python interpreter为当前python版本安装目录,并在Interpreter options中填入-s用以显示nose运行及调试信息

4.2 执行测试用例

1) 选中Tests/test_demo.py

2) 鼠标右键选择Run 'Nosetests in test_demo.py'即可执行测试

3) 也可使用快捷键执行测试:Ctrl+Shift+F10

4) 在脚本中使用快捷键Ctrl+Shift+F10,会单独执行选中的test class下的一个test func

5.参考资料

1. http://nose.readthedocs.io/en/latest/index.html

2. https://docs.python.org/dev/library/unittest.html

猜你喜欢

转载自blog.csdn.net/u012111923/article/details/80703911