web service接口测试工具选型

时间:2023-03-09 03:24:15
web service接口测试工具选型

1  简介

1.1   范围

1.2   目的

本文档用于指导测试部进行接口测试。

2013-03-11磁针石

#承接软件自动化实施与培训等gtalk:ouyangchongwu#gmail.com qq 37391319 博客:http://blog.****.net/oychw

#版权所有,转载刊登请来函联系

# 深圳测试自动化python项目接单群113938272深圳广州软件测试开发 6089740

#深圳地摊群 66250781武冈洞口城步新宁乡情群49494279

#自动化测试和python群组: http://groups.google.com/group/automation_testing_python

本文网盘下载地址:http://www.kuaipan.cn/file/id_141584322762145478.htm

1.3   缩略语

缩略语

全称

说明

SOAP

Simple Object Access Protocol

WSDL

Web Services Description Language

ATI

Automation Testing Institute

1.4    术语

2  概述

Web service是亚信和公司交互的3大接口之一,涵盖了亚信和网厅以及3Gmate的主要接口。由于公司的开发也无法透视亚信的代码,为此测试有必要对亚信和公司交互的web service接口进行测试。

亚信的Web service基于SOAP。基于成本因素,我们不考虑商业工具。根据ATI的建议,有三大主流测试开源工具。排名第一的SoapUI和排名第二的JMeter以及排名第三的Grinder。同时基于我们的python测试平台,又考察了python相关模块。

评估依据:

1.        功能:能实现正确的web service接口测试。占比40%。

2.        脚本能力:支持良好的结构控制,比如for,if等。占比20%。

3.        扩展性:能python自动化平台能对接。占比15%。

4.        易用性:易学易用。占比15%。

5.        其他:占用率,服务支持,历史因素,性能测试等。占比10%。

3  SoapUI

下面是SoapUI的自我介绍。

SoapUI is a free and open source cross-platformFunctional Testing solution. With an easy-to-use graphical interface, andenterprise-class features, SoapUI allows you to easily and rapidly create andexecute automated functional, regression, compliance, and load tests. In asingle test environment, SoapUI provides complete test coverage and supportsall the standard protocols and technologies. There are simply no limits to whatyou can do with your tests. Meet SoapUI, the world's most complete testingtool!

SoapUI开启之后,加载WSDL文件,就可以修改xml(中间的大窗口)为你想要的值,给服务器端发送请求,响应会很方便地展示在右侧的大窗口上。功能得满分40。

SoapUI的开源版本,不支持脚本开发。脚本能力得分0。

SoapUI的扩展力一般,支持XML,通过python的lxml可以吃力的和python自动化测试平台对接。

扩展性得分5。

SoapUI的界面友好,易学易用,易用性得分15。

其他:SoapUI的占有率比较高,亚信也在使用这个工具;社区支援比较广泛;但性能测试参数无法实现。另外SoapUI有近200M,比较庞大,容易拖慢机器。得分6。

总分:66

4  Jmeter

下面是JMeter的自我介绍。

The ApacheJMeter™ desktop application is open source software, a 100% pure Javaapplication designed to load test functional behavior and measure performance.It was originally designed for testing Web Applications but has since expandedto other test functions.

Jemeter的操作和SoapUI类似。功能得满分40。

Jemeter只支持简单脚本开发,无法实现复杂的数据流程,调试能力一般,脚本能力得分5。

Jemeter的扩展力一般,支持XML,通过python的lxml可以吃力的和python自动化测试平台对接。

扩展性得分5。

Jemeter的界面友好,易学易用,安装不如SoapUI简单,易用性得分12。

其他:Jemeter在性能测试有非凡的能力,但是参数化有点吃力,得分8。

总分:70

5       Grinder

下面是Grinder的自我介绍。

The Grinder is a JavaTMload testing framework that makes it easy to run a distributed test using manyload injector machines. It is freely available under a BSD-style open-sourcelicense.

Grinder要书写脚本,功能部分满分40。

Grinder支持python脚本开发,控制结构强大,调试能力一般,脚本能力得分15。

Grinder的扩展力一般,支持XML,python和python自动化平台对接。扩展性得分15。

Grinder的界面友好,安装配置略多,脚本上手有一定难度,必须通过类封装,易用性得分6。

其他:Grinder在性能测试有非凡的能力,输出结果一般,得分8。

总分:84

6       Suds

Suds是python的一个SOAP外部模块。下面是Suds的自我介绍。

Suds is a lightweight SOAPpython client for consuming Web Services.

Features

No class generation

Provides an object API.

Reads wsdl at runtime for encoding/decoding

Supports the following SOAP binding styles:

Document/Literal

RPC/Literal

RPC/Encoded

Provides objectification of WSDL defined:

Types (objects)

Enumerations

Service and type objects provide inspectionvia print

Supports unicode

HTTP authentication

Basic WS-Security

Suds的操作和Grinder类似。功能得满分40。

Suds支持完整脚本开发,调试能力强大,脚本能力得分20。

Suds的扩展力强大,支持XML, python和python自动化测试平台对接。

扩展性得分15。

Suds的界面是python的编辑器,对初学者有一定难度,安装不如SoapUI简单,易用性得分9。

其他:Suds不具备性能测试功能,但是可以和thread,multiprocess等实现性能测试,得分6。

总分:90

Suds的脚本开发和XML类似,支持结构式程序开发,看起来比Grinder要简洁。

脚本开发的步骤如下:

1,  导入suds库

2,  连接服务器

3,  定义要调用函数的参数

4,  发送请求

5,  处理结果

脚本示例:

from suds.client import Client

con =Client('http://192.168.1.8:6030/InfoSystem/ws/imsintf_iImsWrapQueryService?wsdl')

#con =Client('http://112.95.149.76:6030/InfoSystem/ws/imsintf_iImsWrapQueryService?wsdl')

sOper =con.factory.create('sOperInfo')

print sOper

sOper.so_nbr = '808010007'

sOper.busi_code = '6023'

sOper.so_nbr = '808010007'

sOper.so_mode = '1'

sOper.so_date = '2252-06-0714:11:11'

sOper.charge_flag = '0'

sOper.notify_flag = '1'

queryTypeList =con.factory.create('queryTypeList')

print queryTypeList

queryType =con.factory.create('queryType')

queryType.query_type = '12'

queryTypeList.queryType_Item.append(queryType)

queryParam =con.factory.create('sQueryParam')

queryParam.phone_id = '54321@公司.com'

queryParam.query_level = '1'

result =con.service.do_query(sOper, queryTypeList, queryParam)

print "*" * 80

print result

为了和python自动化平台对接,需要封装suds库,通过平台将用例管理起来。

7       其他

Python还有其他很多模块支持SOAP。

SOAPpy、Soapbox、 PySimpleSOAP,Pyws等因为用户不多而没有采用。

Zsi、Elementsoap等因为多年没有人更新而没有采用。

Osa因为无法访问而没有采用。

Requests和urllib2等因为实现相对负责而没有采用。

8  结论

Suda为主兼顾SoapUI。

工具名称

功能40分

脚本能力20分

扩展性15分

易用性15分

其他10分

总分

SoapUI

Jemeter

Grinder

Suds

SoapUI的开源版本和SoapUI由于不具备完整的脚本能力,不能进行大规模测试。

可见Suds和Grinder基本上可以满足我们的需求。但是由于亚信现在使用SoapUI,他们的用例是xml格式描述的,不过亚信内部python使用很广泛。为此为了交流方便,经和亚信杨工确认,准备同时使用Suda为主兼顾SoapUI的方法进行测试。

通过开发suds的封装库,实现自动测试边界值等功能,并通过python自动化测试平台进行管理。