2024年4月30日发(作者:)
SOA Testing 工具介绍
第 1 页 共 56 页
目 录
SOA Testing 工具介绍 ...................................................................................................................... 1
目 录 ................................................................................................................................................ 2
一、 SOAP UI ............................................................................................................................. 3
1. 介绍 ................................................................................................................................... 3
2. 安装、运行SOAP UI ........................................................................................................ 3
3. 使用指南 ........................................................................................................................... 4
1.3.1创建、导入工程 ...................................................................................................... 4
1.3.2执行web service操作请求..................................................................................... 7
1.3.3功能测试(Functional Testing) .................................................................................. 9
1.3.4压力测试 (Load Testing) ....................................................................................... 13
1.3.5 Web Service Mocking ............................................................................................. 19
二、
1.
Apache JMeter ................................................................................................................ 19
介绍 ................................................................................................................................. 19
JMeter简介 .................................................................................................................. 19
JMeter主要特性 .......................................................................................................... 19
安装、运行 Apache JMeter .......................................................................................... 20
使用指南 ......................................................................................................................... 20
3.3.1在JMeter中测试Web Service ............................................................................. 20
3.3.2在JMeter中测试JMS ........................................................................................... 28
PushToTest TestMaker .................................................................................................. 33
介绍 ................................................................................................................................. 33
安装、运行PushToTest_TestMaker ............................................................................... 34
使用指南 ......................................................................................................................... 36
2.3.1基于SOAP的Web Service的测试和监控 ........................................................... 37
2.
3.
三、
1.
2.
3.
第 2 页 共 56 页
SOA Testing工具介绍
一、 SOAP UI
1. 介绍
Soap ui提供一个工具通过soap/http来检查,调用,实现web service和web service的功
能/负载/符合性测试。该工具既可作为一个桌面应用软件使用,也可利用插件集成到Eclipse,
maven2.X,netbeans和intellij中使用。
利用该工具可以方便快速的验证、测试WebService;同时可以作为WebService性能测试
工具。
官方网址:/
下载地址:/projects/soapui
2. 安装、运行SOAP UI
根据下面的步骤来安装、运行soapUI:
从站点t/ ,通过Java WebStart可以在线安装最新的版
本:
从站点sourceforge(/projects/soapui),下载安装soapUI
的Windows版本,该版本包括了需要的Java运行环境(JRE1.5)。如果你不确
定你的系统已经安装了合适的JRE,或者你想有开始菜单并且以后可以卸载,可以
用该版本安装:
第 3 页 共 56 页
SOA Testing工具介绍
从站点sourceforge(/projects/soapui),下载二进制发布物
(例如:””),手工解压缩,运行bin目录下面的
或者脚本(你的系统需要安装好java环境)
无论上面的那种安装方式,soapUI将会以一个空的工作空间开始。
3. 使用指南
1.3.1创建、导入工程
安装并运行soapUI之后,你就可以创建第一个soapUI工程了。
右击左侧导航面板中的工作空间节点,选择”New WSDL Project。
在工程被保存前,应该填写工程名字和相应的本地WSDL文件。
上面的内容填写好之后,将会帮你在工作空间创建一个空的工程。
第 4 页 共 56 页
SOA Testing工具介绍
Initial WSDL:输入wsdl 的地址
第 5 页 共 56 页
SOA Testing工具介绍
也可以通过wsdl URL的方式增加一个web service:
右击工程节点,选择” Add WSDL from URL”
输入WSDL接口的url:
/AWSECommerceService/
增加amazon的Web服务,选择”OK”按钮
soapUI会提示你是否为每个操作创建一个默认的请求,通常选择”Yes”按钮
soapUI为amazon的端口类型” AWSECommerceServicePortType”创建了一
个SOAP/Http绑定,并且为每一个操作创建了一个节点。
第 6 页 共 56 页
SOA Testing工具介绍
1.3.2执行web service操作请求
上面操作已经增加了web service服务,接下来可以执行请求了。在上面增加接口的时候,
已经根据WSDL的Schema定义为每一个操作创建了默认请求。
展开接口下面的任何一个操作节点,能够看到创建的Request 1节点
双击请求节点,在soapUI的右侧会出现请求编辑器(参照下图)
第 7 页 共 56 页
SOA Testing工具介绍
请求编辑器分为三部分
➢ 顶部的工具栏,包含一组请求相关的动作、操作
➢ 左边是请求区域
➢ 右边是响应区域
soapUI默认生成的请求中,”?”表示需要被替换的内容。根据需要,可以替换或者删
除掉这些值。通过按下工具栏最左边的按钮(绿色箭头)来发送一个请求
请求会在后台执行,响应内容会出现在编辑器的右边
第 8 页 共 56 页
SOA Testing工具介绍
1.3.3功能测试(Functional Testing)
在SOAP UI中 功能测试包括对web service本身方法函数的调用测试(单元测试),也包
括对一系列操作集合的测试(集成测试)。
继续在上一部分内容基础上完成TestSuite/TestCase,步骤如下:
1.3.3.1从SOAP Request 生成 Web Service TestSuite/TestCase
1) 打开request界面,选中菜单栏第二个按钮,生成TestCase
或者在左侧展开具体service request中,右击增加request到TestCase
第 9 页 共 56 页
SOA Testing工具介绍
2) 如果工程没有生成过
TestSuites 或TestCases 则根据向导可以生成一个新的TestSuite和
TestCase
第 10 页 共 56 页
SOA Testing工具介绍
在TestCase窗口点击“运行run”按钮,可以测试得到TestCase结果;
1.3.3.2在TestCase中增加断言Assertions
1) 双击TestSteps中的测试request,在request菜单栏中选择第2项增加断言
第 11 页 共 56 页
SOA Testing工具介绍
2) 增加一个
Schema Compliance的断言,该断言会对soap response和wsdl/schema进行校验;
绿色显示该校验全部通过:
1.3.3.3运行Web Service Test
双击导航中TestCase节点,在菜单项中运行该Test Case 得到结果;
第 12 页 共 56 页
SOA Testing工具介绍
1.3.4压力测试 (Load Testing)
在SOAP UI中 压力测试主要包括如下一些特性:
1) 在不同压力测试场景下测试webService的性能;
2) 得到保证webservice功能级可用在不同压力测试下的条件;
3) 同时运行不同的测试场景,得到他们之间是否会相互影响;
在进行压力测试之前,完成TestCase场景设计,这里需要在上面Test Step中在增加
2个request:
第 13 页 共 56 页
SOA Testing工具介绍
1.3.4.1为TestCase增加压力测试LoadTest
1) 右击导航TestCase节点 新建Load Test:
第 14 页 共 56 页
SOA Testing工具介绍
确定 生成Load Test:
2) 配置LoadTest相关属性:
这里设置 运行时间40秒,测试线程6,测试策略:simple,测试延时1秒
3) 运行LoadTest查看运行结果:
第 15 页 共 56 页
SOA Testing工具介绍
1.3.4.2在LoadTest中增加断言Assertions
1) 在LoadTest中配置LoadTest Asserttions:
在LoadTest底部工具栏中选择LoadTest Asserttions -> Add Assertion
选择Step Maximum 然后点 确定:
第 16 页 共 56 页
SOA Testing工具介绍
设置该断言的相关属性:
名称,最小请求数,最大执行时间,最大错误数,测试步骤等 如上图所示
2) 再次执行该LoadTest,查看断言结果:
3) 双击断言出错的日志栏,查看进入此断言的soap request信息
第 17 页 共 56 页
SOA Testing工具介绍
1.3.4.3查看LoadTest图表统计结果
在LoadTest窗口菜单栏运行 Show the statistics graph:
第 18 页 共 56 页
SOA Testing工具介绍
1.3.5 Web Service Mocking
二、 Apache JMeter
1. 介绍
JMeter简介
Apache jmeter 是一个100%的纯java桌面应用,用于压力测试和性能测量。它最初被设计用于Web
应用测试但后来扩展到其他测试领域。
Apache jmeter 可以用于对静态的和动态的资源(文件,Servlet,Perl脚本,java 对象,数据库和查
询,FTP服务器等等)的性能进行测试。它可以用于对服务器,网络 或对象模拟繁重的负载来测试它们的
强度或分析不同压力类型下的整体性能。你可以使用它做性能的图形分析或在大并发负载测试你的服务器/
脚本/对象。
另外,JMeter能够通过让你们用断言创造测试脚本来验证我们的应用程序是否返回了我们期望的结果,
从而帮助我们回归测试我们的程序。为了最大的灵活性,JMeter允许我们使用正则表达式创建断言。
JMeter主要特性
1. 能够对HTTP和FTP服务器进行压力和性能测试, 也可以对任何数据库进行同样的测试(通过
JDBC)。
2. 完全的可移植性和100% 纯java。
3. 完全 Swing 和轻量组件支持(预编译的JAR使用 .*)包。
4. 完全多线程 框架允许通过多个线程并发取样和 通过单独的线程组对不同的功能同时取样。
5. 精心的GUI设计允许快速操作和更精确的计时。
6. 缓存和离线分析/回放测试结果。
7. 高可扩展性:
o
可链接的取样器允许无限制的测试能力。
o
各种负载统计表和可链接的计时器可供选择。
o
数据分析和可视化插件提供了很好的可扩展性以及 以及个性化。
o
具有提供动态输入到测试的功能(包括Javascrīpt)。
o
支持脚本变成的取样器(在1.9.2及以上版本支持BeanShell)。
官方网址: /jmeter/
下载地址: /site/downloads/downloads_
中文参考手册:/pages/?pageId=5566
第 19 页 共 56 页
SOA Testing工具介绍
2. 安装、运行 Apache JMeter
下载得到文件,解压缩后运行jakarta-jmeter-2.3.1bin
3. 使用指南
3.3.1在JMeter中测试Web Service
3.3.1.1添加用户(线程组)
你想处理每个JMeter测试计划的第一步是添加线程组元件。线程组告诉JMeter你
想模拟的用户数,用户发送请求的频率,和发送请求的数量。
第 20 页 共 56 页
SOA Testing工具介绍
下一步,你需要修改默认配置。如果你还没有选择线程组元件,在树里选择它。现
在在JMeter窗口右部你应该可以看到线程组控制面板。
第 21 页 共 56 页
SOA Testing工具介绍
第 22 页 共 56 页
SOA Testing工具介绍
3.3.1.2增加 WebService Requests
修改名称:WebService(SOAP) Request
第 23 页 共 56 页
SOA Testing工具介绍
添加wsdl url: 127.0.0.1:8090/axis2/services/AccountManagerService?wsdl
如果WSDL文件加载正确,"Web方法"下拉框将会增加元素。如果下拉框仍然为空,它
说明得到WSDL文件有问题。你可以使用浏览器读取XML测试WSDL。例如,如果你测试一
个IIS web服务,URL会像这样:
localhost/myWebService/?WSDL
。在
这 点,"SOAPAction","URL","SOAPData"应该为空。
下一步,选择web方法并点击"配置"。取样器应该会填充"URL"和"SOAPAction"文本域。加入
WSDL文件有效,正确的SOAPAction会输入。
第 24 页 共 56 页
SOA Testing工具介绍
3.3.1.3增加监听器 存储测试结果:
第 25 页 共 56 页
SOA Testing工具介绍
第 26 页 共 56 页
SOA Testing工具介绍
3.3.1.4运行测试计划:
查看测试统计结果:
第 27 页 共 56 页
SOA Testing工具介绍
3.3.2在JMeter中测试JMS
3.3.2.1创建JMS 测试计划
第 28 页 共 56 页
SOA Testing工具介绍
3.3.2.2创建JMS 线程组
第 29 页 共 56 页
SOA Testing工具介绍
3.3.2.3添加创建JMS点对点取样器
配置取样器信息:
第 30 页 共 56 页
SOA Testing工具介绍
3.3.2.4添加一个监听器浏览/保存测试结果
第 31 页 共 56 页
SOA Testing工具介绍
3.3.2.5运行测试计划:
第 32 页 共 56 页
SOA Testing工具介绍
查看结果:
三、 PushToTest TestMaker
1. 介绍
TestMaker是PushToTest的一个Web service测试工具。它需要Java1.4及以上.安装很简单,
一旦设置好JAVA_HOME环境变量后,TestMaker启动和运行都没有问题。
TestMaker的测试是用称为“测试代理”(test agents)的脚本来完成的。TestMaker提供一个“代理
向导”(Agent Wizard)来读入WSDL定义并自动创建一个测试代理的基本结构。
需要指出的是:TestMaker不仅仅能测试Web services;它还能被用于测试Web应用程序。与
TestMaker绑定在一起的还有一个网络监视工具,能监视浏览器和目标Web应用之间的HTTP通信,
并且从交互过程中产生测试用例。
由代理向导(Agent Wizard)创建的基本的测试代理(test agent)是很简单的:它知道目标服务的
Web方法,并且执行不会出现错误,但是它没有真正执行任何请求、响应或者测试结果。我发现我
需要检查一个测试代理例子的源代码来填写缺少的内容。
第 33 页 共 56 页
SOA Testing工具介绍
TestMaker可以在命令行执行,因此,你的测试代理(test agent)可以被自动化系统执行。另外,
TestMaker还绑定了Apache Axis TCPMonitor工具,它让你可以监视某个端口的HTTP信息交换。
这对于检查内部请求/响应对来决定如何编写Jython测试代码时会很有用。
商业的TestMaker版本添加了XSTest,提供性能测试和容量测试(Scalabillity testing),一个监
视面板提供实时的结果,报告能力,还有TestNetWork – 能远程执行测试代理(test agent),因此,
允许你搭建测试代理服务器来同时测试目标Web应用程序。
TestMaker的文档很好,工具的感觉像专业的应用。但是,很难掌握和精通。需要留出大量时间
来阅读指南和分析那些例子的源代码。
官方网址:/
2. 安装、运行PushToTest_TestMaker
下载地址:/Downloads/tmdownloadfiles
下载文件:
这里我们下载使用:Download PushToTest TestMaker Installer, 141 Mbytes
安装过程:
解压缩下载文件PushToTest_TestMaker_Install_后 运行 setup_
第 34 页 共 56 页
SOA Testing工具介绍
运行PushtoTest
首先出现向导画面:
第 35 页 共 56 页
SOA Testing工具介绍
根据向导进行选择,进入主界面,安装完成:
3. 使用指南
说明:使用PushToTest TestMaker.可以进行如下方面测试:
1) Testing and Monitoring Web Applications
第 36 页 共 56 页
SOA Testing工具介绍
Build A Functional Test of a Web-browser-based application
Build A Scalability and Performance Load Test of a Web-browser-based application
Build A Service Monitor of a Web-browser-based application
2) Testing and Monitoring SOAP-based Web Services
Build A Functional Test of a Web service
Build A Scalability and Performance Load Test of a Web service
Build A Service Monitor of a Web service
3) Adding Advanced Features To Tests
Working with Dynamic Scripting Languages (Java, Jython, Python, Ruby, Groovy,
JavaScript)
Dynamic Data Production Libraries (DPL)
4) Email-based Test Tutorials
下面展开介绍第2中测试 基于SOAP的Web Service的测试和监控
2.3.1基于SOAP的Web Service的测试和监控
2.3.1.1运行SOAP UI创建Web Service Test Unit
1) 运行TestMaker,选择功能tools->start SOAP UI
第 37 页 共 56 页
SOA Testing工具介绍
2) 根据wsdl文件或者wsdl URL创建soap ui 工程
具体可以参见第一章1.3使用指南
其中wsdl URL地址可以参考:
/axis/services/MessageService?wsdl
第 38 页 共 56 页
SOA Testing工具介绍
3) 运行服务请求request
第 39 页 共 56 页
SOA Testing工具介绍
将?问号出换成
求结果:
第 40 页 共 56 页
SOA Testing工具介绍
4) 创建TestSuite
第 41 页 共 56 页
SOA Testing工具介绍
第 42 页 共 56 页
SOA Testing工具介绍
5) 运行该单元测试Unit Test,测试通过得到测试结果:
第 43 页 共 56 页
SOA Testing工具介绍
2.3.1.2在TestMaker中进行WebService功能测试(Functional Test)
1) 点击功能菜单项New Functional Test生一个新的New Functional Test
第 44 页 共 56 页
SOA Testing工具介绍
TestMaker 生成一个测试场景文件,同时打开一个新控制面板:
2) 在控制面板中可以看到 run,stop, run, pause, stop, edit, expand:
点击 EDIT 按钮 输入测试的代码:可以将如下部分拷贝过去
第 45 页 共 56 页
SOA Testing工具介绍
xmlns:xsi="/2001/XMLSchema-instance" xsi:schemaLocation="/tm5 " version="2.0"> langtype="soapui"/>
xmlns="/tm5" 第 46 页 共 56 页 SOA Testing工具介绍 各个elment的说明如下: • • • • • • test. In this tutorial we are using the default TestNode that runs on the localhost (automatically installed when you installed TestMaker.) to operate the test the unit test one or more times with a single concurrent virtual user (CVU) o make up this functional test. In this tutorial we have only a single unit test recorded. o testclass, method, and langtype attributes identify the TestGen4Web recorded unit test. This is the test the 3) 在控制面板点 RUN 按钮 运行测试场景: 第 47 页 共 56 页 SOA Testing工具介绍 2.3.1.3在TestMaker中进行WebService压力测试(LoadTest) 1) TestMaker中 压力测试(LoadTest)方法XSTest的介绍: Load testing identifies the throughput of a service by making multiple concurrent requests to a service and observing the upper range of the service's ability to respond to concurrent requests. Load testing is useful to identify the number of users a service can handle given a certain number of resources (CPUs, network bandwidth, memory, threads, database connections, servers, and more.) Scalability testing identifies the scalability index of a service as the service handles increasing levels of concurrent requests. Scalability testing is useful to forecast resource needs (CPUs, network bandwidth, memory, threads, database connections, servers, and more.) Scalability testing enables a business to make tradeoffs at development and configuration time. Performance testing identifies changes in the scalability index of a service as the service programming changes and the service resources change. For instance, when installing a new patch to a database a performance test will identify an improvement in performance as compared to a previous test run. 第 48 页 共 56 页 SOA Testing工具介绍 2) 新建测试场景,点击 菜单栏按钮 New Load Test 第 49 页 共 56 页 SOA Testing工具介绍 3) 在控制面板中 点击 EDIT 按钮,输入测试代码,可以拷贝如下代码: xsi:schemaLocation="/XSD/" version="2.0"> 第 50 页 共 56 页 SOA Testing工具介绍 其中 对于压力测试(SOAP Load Test )配置文件代码的说明如下: • • • The from the functional test in Tutorial 1. threads to operate a unit test over-and-over for the period of the test. The values tell TestMaker how many threads to operate. For this test, TestMaker instantiates 10 concurrently running threads, operates the threads for the 1 minute period of the test, tears-down the running threads, and then operates 20 new threads for the period of the test. In a system with linear scalability twice the number of concurrently running request agents should generate twice the throughput, as measured in transactions per second (TPS) at the client. • o usecase and the next. Once the before operating the o 1000 millisecond (1 second) delay between starting each of the concurrently running threads. This is done to not overwhelm the resources of the load generating system (the TestNode) and the target host system. o millisecond (1/10 of 1 second) delay once a test period (set by the is completed before the test creates the next set of threads. o seconds, or 1 minute) time to operate the threads for each threads. 4) 运行测试场景SOAP Load Test : 第 51 页 共 56 页 SOA Testing工具介绍 显示结果如下: 5) 打开控制面板,可以查看图表显示的测试结果统计等: 第 52 页 共 56 页 SOA Testing工具介绍 2.3.1.4在TestMaker中建立基于SOAP-WebService的Monitor 1) 在菜单栏里 点击按钮 New Service Monitor : 第 53 页 共 56 页 SOA Testing工具介绍 2) 在控制面板中点击 EDIT 按钮 输入测试代码,可以参考如下: xmlns:xsi="/2001/XMLSchema-instance" xsi:schemaLocation="/tm5 C:DOCUME~1llaraMYDOCU~" version="2.0"> xmlns="/tm5" location="localhost:8080/TestNetwork/ws/TestNode"/> path="example_agents/soapui_examples/PTT_"/> 第 54 页 共 56 页 SOA Testing工具介绍 testclass="testsuite" method="testcase" langtype="soapui"/> 关于该配置文件的说明: • • • The same from the functional test in Tutorial 1 and the load test in Tutorial 2. tells TestMaker to operate this test and then wait for 10 seconds (10,000 milliseconds) and then to repeat the test. exceptions are logged but do not stop the monitor. 3) 在控制面板中点击 RUN 按钮 运行,结果如下: 第 55 页 共 56 页 SOA Testing工具介绍 第 56 页 共 56 页


发布评论