1 簡介
1.1 范圍
1.2 目的
本文檔用於指導測試部進行接口測試。
2013-03-11磁針石
#承接軟件自動化實施與培訓等gtalk:ouyangchongwu#gmail.com qq 37391319 博客:http://blog.csdn.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的擴展力強大,支持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 |
40 |
0 |
5 |
15 |
6 |
66 |
| Jemeter |
40 |
5 |
5 |
12 |
8 |
70 |
| Grinder |
40 |
15 |
15 |
6 |
8 |
84 |
| Suds |
40 |
20 |
15 |
6 |
6 |
87 |
SoapUI的開源版本和SoapUI由於不具備完整的腳本能力,不能進行大規模測試。
可見Suds和Grinder基本上可以滿足我們的需求。但是由於亞信現在使用SoapUI,他們的用例是xml格式描述的,不過亞信內部python使用很廣泛。為此為了交流方便,經和亞信楊工確認,准備同時使用Suda為主兼顧SoapUI的方法進行測試。
通過開發suds的封裝庫,實現自動測試邊界值等功能,並通過python自動化測試平台進行管理。
