SoapUI中文教程

合集下载

SoapUI教程:功能和非功能测试说明书

SoapUI教程:功能和非功能测试说明书

About the T utorialSoapUI is an open-source tool used for functional and non-functional testing, widely used in WebServices testing. This is a brief tutorial that introduces the readers to the basic features and usage of SoapUI. The tutorial will guide the users on how to utilize the tool in WebService and other non-functional testing.AudienceThis tutorial has been prepared for beginners to help them understand how to use the SOAPUI tool.PrerequisitesAs a reader of this tutorial, you should have a basic understanding of the client/server environment, and knowledge of SOAP, WSDL, XML, and XML namespace.Copyright & DisclaimerCopyright 2018 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher.We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or inthistutorial,******************************************iT able of ContentsAbout the Tutorial (i)Audience (i)Prerequisites (i)Copyright & Disclaimer (i)Table of Contents ....................................................................................................................................... i i1.SOAP ─ INTRODUCTION (1)2.SOAP ─ MESSAGES (2)3.SOAP ─ WHAT IS REST? (4)4.SOAPUI ─ INTRODUCTIO N (5)5.SOAPUI ─ CAPABILITIE S (6)6.SOAPUI ─ NG PRO (8)7.SOAPUI ─ INSTALLATIO N & CONFIGURATION (9)8.SOAPUI ─ WSDL (19)WSDL Usage (19)Understanding WSDL (20)Format and Elements (20)WSDL – Port Type (22)Patterns of Operation (22)ii9.SOAPUI ─ PROJECT (26)Create a SOAP Project (26)Add a WSDL (28)Details View (30)10.SOAPUI – TESTSUITE (33)Creation of TestSuite (33)11.SOAPUI – TESTCASE (37)12.SOAPUI ─ TESTSTEP (39)13.SOAPUI ─ REQUEST & R ESPONSE (42)Request Setup (42)Response (42)HTTP Request (43)HTTP Response (44)14.SOAPUI ─ PRO PERTIES (46)Defining Properties (46)Accessing Property (47)15.SOAPUI ─ PROPERTY TRANSFER (49)Adding Property Transfer (49)Transferring a Property (50)iii16. SOAPUI ─ LOGS PANE (54)SOAP UI Log (55)HTTP Log (55)Error Log (56)Memory Log (56)17.SOAPUI – ASSERTIONS (57)18.ASSERTION ─ CONTAINS (60)19.ASSERTION ─ NOT CONT AINS (63)20.ASSERTION ─ XPATH MA TCH (65)21.ASSERTION – XQUERY MATCH (68)22.ASSERTION ─ SCRIPT (70)23.SOAPUI – TROUBLESHOOTING (74)24.SOAPUI ─ PERFORMANCE TESTING (76)Types of Performance Testing (76)Key Aspects in Web Service (76)25.SOAPUI ─ LOAD TESTIN G (78)Creation of Load Test (78)Execution of Load Test (79)Adding an Assertion (81)26.SOAPUI ─ RESTFUL WEB SERVICES (84)27.REST ─ PROJECT SETUP (85)iv28.REST ─ WADL (88)29.REST ─ REQUEST (90)30.REST ─ RESPONSE (94)31.REST ─ HTTP METHODS (97)POST (97)GET (97)PUT (98)PATCH (98)DELETE (99)32.SOAPUI ─ JDBC CONNEC TION (100)33.SOAPUI ─ JDBC PROPER TY (103)34.SOAPUI – JDBC ASSERTION (104)vSOAP is the acronym for Simple Object Access Protocol. It is defined by World Wide Web Consortium (W3C) at /TR/2000/NOTE-SOAP-20000508 as follows: SOAP is a lightweight protocol for the exchange of information in a decentralized, distributed environment. It is an XML based protocol that consists of three parts: an envelope that defines a framework for describing what is in a message and how to process it; a set of encoding rules for expressing instances of application-defined data types; and a convention for representing remote procedure calls and responses.SOAP ─ Important FeaturesFollowing are some important features of SOAP.∙It is a communication protocol designed to communicate via Internet.∙It can extend HTTP for XML messaging.∙It provides data transport for Web services.∙It can exchange complete documents or call a remote procedure.∙It can be used for broadcasting a message.∙It is both platform and language independent.∙It is the XML way of defining what information is sent and how.∙It enables client applications to easily connect to remote services and invoke remote methods.Although SOAP can be used in a variety of messaging systems and can be delivered via a variety of transport protocols, the initial focus of SOAP is remote procedure calls transported via HTTP. Other frameworks such as CORBA, DCOM, and Java RMI provide similar functionality to SOAP, but SOAP messages are written entirely in XML and are therefore uniquely platform- and language-independent.1A SOAP message is an ordinary XML document containing the following elements:∙Envelope: Defines the start and the end of the message. It is a mandatory element.∙Header: Contains any optional attributes of the message used in processing the message, either at an intermediary point or at the ultimate end-point. It is an optional element.∙Body: Contains the XML data comprising the message being sent. It is a mandatory element.∙Fault:An optional Fault element that provides information about errors that occur while processing the message.All these elements are declared in the default namespace for the SOAP envelope: /2001/12/soap-envelopeThe default namespace for SOAP encoding and data types is:/2001/12/soap-encodingNote: All these specifications are subject to change. Thus, keep updating yourself with the latest specifications available on the W3 website.SOAP ─ Message StructureThe following block depicts the general structure of a SOAP message:233.REST is the acronym for Representational State Transfer. It can be defined as an architectural style of designing softwares. REST is not a specification or W3C standard. Hence, it is easier to work with RESTful Services. It doesn’t require any middleware specification framework.REST ─ Important FeaturesFollowing are some important features of REST.∙It relies on stateless, client-server, cacheable communication protocol – virtually in all cases, HTTP is used.∙It is light-weighted alternative of WebService and RPC (Remote Procedure Call) like SOAP-WSDL.∙It represents everything in unique ID or URIs.∙It makes the use of standard HTTP methods, such as GET, POST, PUT, DELETE.∙It links sources together.∙REST resources could have multiple representations.∙Any named information is considered as a Resource. For example: An image, a person, a document, all can be considered as an example of resource and represented as a unique ID or a URI.∙World Wide Web itself, based on HTTP, can be viewed as REST based architecture. REST services are Platform and Language independent. Since it is based on HTTP standards, it can easily work in the presence of firewalls. Like WebServices, REST doesn’t offer any in-built security, session management, QoS guarantee but these can be added by building on top of HTTP. For encryption, REST can be used on top of HTTPS.45SoapUI is a tool which can be used for both functional and non-functional testing. It is not limited to web services, though it is the de-facto tool used in web services testing.SoapUI ─ Important FeaturesFollowing are some important features of SoapUI.∙ It is capable of performing the role of both client and service.∙It enables the users to create functional and non-functional tests quickly and in an efficient manner using a single environment.∙ It is licensed under the terms of the GNU Leaser General Public Licence (LGPL).∙ It is purely implemented using JAVA platform.∙ It supports Windows, Mac, multiple Linux dialects.∙It allows testers to execute automated functional, regression, compliance, and load tests on different Web API.∙It supports all the standard protocols and technologies to test all kinds of APIs.SOAP UI can be used to test complete RESTful API and SOAP Web Service testing. It supports Functional Testing, Performance Testing, Interoperability Testing, Regression Testing, Load Testing, and much more.It is user friendly as well as it is easy to convert functional test into non-functional tests such as Load, Stress testing.6S OAP UI is rich in the following five aspects:∙ Functional Testing ∙ Security Testing ∙ Load Testing∙ Protocols and Technologies ∙Integration with other toolsLet’s learn more about each of these capabilities.Functional Testing∙ SOAP UI allows the testers to write functional API tests in SOAP UI.∙ SOAP UI supports Drag-Drop feature that accelerates the script development.∙SOAP UI supports debugging of tests and allows testers to develop data driven tests.∙SOAP UI supports multiple environments making it easy to switch among QA, Dev, and Prod environments.∙SOAP UI allows advanced scripting (the tester can develop their custom code depending on the scenarios).Security Testing∙ SOAP UI performs a complete set of vulnerability scan.∙ SOAP UI prevents SQL Injection to secure the databases.∙ SOAP UI scans for stack overflows, caused by documents huge in size.∙SOAP UI scans for cross-site scripting, which occurs when service parameters are exposed in messages.∙SOAP UI performs fuzzing scan and boundary scan to avoid erratic behavior of the services.Load Testing∙ SOAP UI distributes the load tests across n number of LoadUI agents. ∙ SOAP UI simulates high volume and real-world load testing with ease.∙SOAP UI allows advanced custom reporting to capture performance parameters.7∙SOAP UI allows end-to-end system performance monitoring.Protocols& TechnologiesSOAP UI supports a wide range of protocols:∙SOAP – Simple Object Access Protocol∙WSDL – Web Service Definition Language∙REST – Representational State Transfer∙HTTP – Hyper Text Transmission Protocol∙HTTPS – Hyper Text Transmission Protocol Secured∙AMF –Action Message Format∙JDBC – Java Database Connectivity∙JMS – Java Messaging ServiceIntegration w ith O ther T ools∙Apache Maven Project∙HUDSON∙JUnit∙Apache – Ant and more….6.SOAP UI is an open source free version tool with basic features of testing, while SOAP UI NG Pro is a commercialized tool having advanced features of reporting, data-driven functionality and much more.ComparisonThe following table compares and contrasts the various features of SoapUI and SoapUI NG Pro.897.SoapUI is a cross-platform tool. It supports Windows, Linux, and Mac operating systems.Prerequisites∙Processor: 1GHz or higher 32-bit or 64-bit processor.∙RAM: 512MB of RAM.∙Hard Disk Space: Minimum 200MB of hard disk space for installation.∙Operating System Version: Windows XP or later, MAC OS 10.4 or later.∙JAVA: JAVA 6 or later.Download ProcessStep 1: Go to https:/// and click Download SOAP UI.1011Step 2: Click ‘Get It’ to download SOAP UI Open Source. It will start downloading 112MB .exe file in the system. Wait till the download process is complete.12End of ebook previewIf you liked what you saw…Buy it from our store @ https://。

SoapUI使用手册

SoapUI使用手册

SoapUI使用说明zhangrong317@ 1 SoapUI 介绍由于Web 服务是被程序调用的,一般不会提供界面让最终用户或测试人员直接使用,在SoapUI 等工具出现之前,测试人员不得不自己编写程序来测试它,这就要求测试人员花费很大的精力了解底层的接口,调用关系和详细的协议,导致他们不能把注意力集中到测试中。

SoapUI 的出现极大的改变了这一局面。

作为一个开源的工具,SoapUI 强大的功能、易用的界面,吸引了很多用户。

用户可以在SoapUI 中通过简单的操作完成复杂的测试,不需要了解底层的细节,极大的减轻了工作量。

SoapUI 支持多样的测试,例如功能测试,性能测试,回归测试等。

到目前为止SoapUI 的下载量已经超过了100万次,成为了Web服务测试标准和领先的Web 服务测试工具。

它不仅仅可以测试基于SOAP的Web 服务,也可以测试REST风格的Web 服务,后者也是本文介绍的重点。

SoapUI基于Java开发,支持多个平台,安装非常简单。

读者可以到SoapUI 的官方网站下载一个安装包( 本文使用的是Window 版本 3.0.1),直接安装即可。

在该安装包中,包括了一个SoapUI 所需要的JRE1.6 版本。

安装完毕以后,读者需要设置JA V A_HOME 变量指向到相应的JRE 目录,同时修改PATH 变量,将JRE1.6 的bin 目录添加进去。

2 SoapUI使用过程2.1 创建/导入工程安装并运行SoapUI之后,你就可以创建第一个SoapUI工程了。

程序第一次打开时,左侧导航面板上,自动有一个空的Projects工程。

右击左侧导航面板中的工作空间节点“Projects”,选择“New SoapUI Project”。

图表2-1页面弹出“New SoapUI Project”TAB页,填入Project Name,Initial WSDL/WADL可填入URL地址或直接导入WSDL文件,导入文件后,如下图所示:图表2-2默认选上:Create sample requests for all operations?(说明:为每个接口创建一个请求的例子)Creates a TestSuite for the imported WSDL or WADL(说明:为WSDL或WADL创建一个测试包)点击OK按钮后,页面弹出保存工程的提示,以project名称+“- soapui -project.xml”的形式进行命名,因此上述工程在保存时页面给出默认命名为test1_file-soapui-project.xml,直接点击保存即可。

SoapUI5.x使用入门

SoapUI5.x使用入门
Inspur group 2019/8/21
5
一、SoapUI入门—资源添加(新建资源)
Inspur group 2019/8/21
ቤተ መጻሕፍቲ ባይዱ
6
一、SoapUI入门—资源添加(克隆资源)
Inspur group 2019/8/21
7
一、SoapUI入门—参数(资源参数)
Inspur group 2019/8/21
8
一、SoapUI入门—参数(方法参数)
Inspur group 2019/8/21
9
一、SoapUI入门—参数(操作参数)
Inspur group 2019/8/21
10
一、SoapUI入门—参数(操作参数)
说明:
资源的参数是固定的,优先在资源里设置。 操作中添加的参数会在资源参数列表显示参数名,不显示参数
15
一、SoapUI入门—生成测试集
Inspur group 2019/8/21
16
一、SoapUI入门—生成测试集结果
Inspur group 2019/8/21
17
一、SoapUI入门—添加断言(预期结果)
Inspur group 2019/8/21
18
一、SoapUI入门—添加断言(添加结果)
SoapUI入门
2019/06/30
2
一、SoapUI入门
为了避免空洞的讲解,同时为了更好的展示 soapUI 对 REST 服务的测试功能,以云海为例。
Inspur group 2019/8/21
3
一、SoapUI入门—层次结构
Inspur group 2019/8/21
4
一、SoapUI入门—新建项目

SoapUI中文教程

SoapUI中文教程

SoapUI使用说明1 SoapUI 介绍由于 Web 服务是被程序调用的,一般不会提供界面让最终用户或测试人员直接使用,在 SoapUI 等工具出现之前,测试人员不得不自己编写程序来测试它,这就要求测试人员花费很大的精力了解底层的接口,调用关系和详细的协议,导致他们不能把注意力集中到测试中。

SoapUI 的出现极大的改变了这一局面。

作为一个开源的工具,SoapUI 强大的功能、易用的界面,吸引了很多用户。

用户可以在 SoapUI 中通过简单的操作完成复杂的测试,不需要了解底层的细节,极大的减轻了工作量。

SoapUI 支持多样的测试,例如功能测试,性能测试,回归测试等。

到目前为止 SoapUI 的下载量已经超过了100万次,成为了Web服务测试标准和领先的 Web 服务测试工具。

它不仅仅可以测试基于SOAP的Web 服务,也可以测试REST风格的 Web服务,后者也是本文介绍的重点。

SoapUI基于Java开发,支持多个平台,安装非常简单。

读者可以到 SoapUI的官方网站下载一个安装包 ( 本文使用的是 Window 版本 3.0.1),直接安装即可。

在该安装包中,包括了一个 SoapUI 所需要的 JRE1.6 版本。

安装完毕以后,读者需要设置 JAVA_HOME 变量指向到相应的 JRE 目录,同时修改 PATH 变量,将 JRE1.6 的 bin 目录添加进去。

2 SoapUI使用过程2.1创建/导入工程安装并运行SoapUI之后,你就可以创建第一个SoapUI工程了。

程序第一次打开时,左侧导航面板上,自动有一个空的Projects工程。

右击左侧导航面板中的工作空间节点“Projects”,选择“New SoapUI Project”。

图表 2-1页面弹出“New SoapUI Project”TAB页,填入Project Name,Initial WSDL/WADL可填入URL地址或直接导入WSDL文件,导入文件后,如下图所示:图表 2-2默认选上:Create sample requests for all operations?(说明:为每个接口创建一个请求的例子)Creates a TestSuite for the imported WSDL or WADL(说明:为WSDL或WADL创建一个测试包)点击OK按钮后,页面弹出保存工程的提示,以project名称+“- soapui-project.xml”的形式进行命名,因此上述工程在保存时页面给出默认命名为test1_file-soapui-project.xml,直接点击保存即可。

SOAPUI中文教程---生成测试报告

SOAPUI中文教程---生成测试报告

SOAPUI中⽂教程---⽣成测试报告soapUI有⾼度的定制可能性; soapUI Pro中可打印的报告基于⾮常灵活的JasperReports报告引擎。

这些报告是从JasperReports⽣成的特定的基于XML的模板,可以在项⽬和全局层⾯进⾏定制,从⽽使您在创建的所有报告中都能轻松获得通⽤的外观和感觉。

在soapUI中创建可打印报告很容易; 只需从Report对话框中的 Report Type 下拉列表中选择相应的报告,则所选报告将⾃动编译并按配置⽣成。

Quick tip: 要充分了解soapUI Pro中的报告基础架构,您应该很好地掌握JasperReports及其模板语⾔的⼯作原理,否则下⾯的⼀些解释可能很难放在内容中1. 报告管理soapUI项⽬窗⼝包含⼀个报告选项卡,其中所有全局和项⽬级报告都可⽤:不同的⼦选项卡可让您访问主报表,⼦报表和模板以及项⽬级报表参数的底层XML。

可以根据需要创建,删除和编辑项⽬级别项⽬,但不能在soapUI中修改全局项⽬。

它们必须在⽂件系统中进⾏修改,并重新加载顶部⼯具栏中的“重新加载”按钮以进⾏更新(稍后再进⾏更改)。

2. 报告结构报表及其相应的DataSource:例如,MetricsReport⼦报表从ReportMetrics获取其数据,并包含在所有主要报告中,并具有以下语法:y="98" width="535" height="30" isRemoveLineWhenBlank="true"> $P{IncludeResults} ... $P{TestSuiteMetrics} "subreport:MetricsReport"TestSuiteMetrics暴露的字段在MetricsReport模板中相对定义:... ...Templates允许管理模板XML的公共块。

soapUI-使用手册

soapUI-使用手册
3.4 soapUI 模拟客户端 ....................................................................................................................................3-19 3.4.1 任务说明 ..........................................................................................................................................3-19 3.4.2 操作示例 ..........................................................................................................................................3-19
4 soapUI 其他功能介绍 .................................................................................................................4-1
4.1 4.3 设置全局变量........................................................................................................................................4-2 4.2 Web Service 性能测试..................................................................................................................................4-3

soapui接口测试教程

soapui接口测试教程

soapui接口测试教程SoapUI接口测试是一种常用的测试方法,它可以帮助我们验证接口的功能和性能。

以下是一个简单的教程,旨在帮助您了解如何使用SoapUI进行接口测试。

1. 下载和安装SoapUI: 首先,您需要从SoapUI官方网站下载并安装最新版本的SoapUI。

安装完成后,启动SoapUI。

2. 创建一个新项目: 打开SoapUI后,单击“File”菜单,然后选择“New SoapUI Project”。

在弹出窗口中,输入项目名称,并选择合适的WSDL文件或接口地址,然后单击“OK”。

3. 添加测试用例: 在项目窗口中,右键单击“Test Suites”,然后选择“New Test Suite”。

在弹出窗口中,输入测试套件的名称,并单击“OK”。

然后,右键单击新创建的测试套件,选择“New Test Case”,并为测试套件命名。

4. 设置测试步骤: 在测试用例窗口中,右键单击测试套件,然后选择“New Test Step”。

在弹出窗口中,选择适当的测试步骤类型,如“SOAP Request”或“REST Request”,然后单击“OK”。

根据接口要求,填写相应的请求和参数。

5. 添加断言: 在每个测试步骤中,您可以添加断言以验证接口的返回结果是否符合预期。

右键单击测试步骤,选择“Add Assertion”。

在弹出窗口中,选择合适的断言类型,如“Content”或“Response SLA”,并设置断言条件。

6. 运行测试: 在项目窗口中,选择要运行的测试用例或测试套件,然后单击工具栏上的“Run”按钮。

SoapUI将发送请求并收到相应的响应。

您可以查看每个测试步骤的结果,并检查接口是否按预期工作。

7. 生成报告: 在测试运行完成后,您可以生成测试报告以汇总测试结果。

在项目窗口中,选择要生成报告的测试用例或测试套件,然后单击工具栏上的“Generate Report”按钮。

选择报告格式和保存位置,然后单击“OK”。

soapui参数list传递

soapui参数list传递

soapui参数list传递在SoapUI中,可以使用参数列表(Parameter List)来传递多个参数值。

参数列表是一种特定的参数类型,它允许在一个请求中传递多个参数值,并可以根据需要进行动态修改。

以下是关于如何在SoapUI中使用参数列表的详细说明。

1.创建参数列表在SoapUI中,可以通过以下步骤创建参数列表:-在项目导航树中选择要使用参数列表的测试用例或测试步骤。

-在右侧的“属性”面板中,选择“新建参数列表”的选项。

-输入参数列表的名称,并点击“确定”按钮。

2.添加参数值一旦创建了参数列表,可以通过以下方式添加参数值:-在“属性”面板中选择参数列表。

-点击“新建参数值”的选项,输入参数值的名称和值,并点击“确定”按钮。

-可以根据需要添加更多的参数值。

3.使用参数列表使用参数列表的步骤如下:-在测试用例或测试步骤中的请求中,选择要替换为参数列表的参数值。

- 将参数值替换为`"${参数列表名称#参数值名称}"`的形式。

例如,如果参数列表名称为“myList”,参数值名称为“param1”,则替换后的形式为`${myList#param1}`。

-运行测试用例或测试步骤时,参数值将从参数列表中动态获取。

4.修改参数列表的值可以在测试运行时动态修改参数列表中的参数值。

可以通过以下方式进行修改:-在弹出的参数列表对话框中,选择要修改的参数值。

-修改参数值的名称或值,并点击“确定”按钮。

-在测试运行期间,参数值将根据最新的修改值进行更新。

5.使用循环语句在一些情况下,可能需要使用循环语句来迭代参数列表中的参数值。

可以通过以下方式实现循环功能:- 在测试用例或测试步骤的Groovy脚本中,编写循环语句,并使用Groovy语法来访问参数列表中的参数值。

- 在循环中使用`context.expand('${参数列表名称}')`来获取参数列表的值,并在每次迭代中访问不同的参数值。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

SoapUI使用说明1 SoapUI 介绍由于 Web 服务是被程序调用的,一般不会提供界面让最终用户或测试人员直接使用,在 SoapUI 等工具出现之前,测试人员不得不自己编写程序来测试它,这就要求测试人员花费很大的精力了解底层的接口,调用关系和详细的协议,导致他们不能把注意力集中到测试中。

SoapUI 的出现极大的改变了这一局面。

作为一个开源的工具,SoapUI 强大的功能、易用的界面,吸引了很多用户。

用户可以在 SoapUI 中通过简单的操作完成复杂的测试,不需要了解底层的细节,极大的减轻了工作量。

SoapUI 支持多样的测试,例如功能测试,性能测试,回归测试等。

到目前为止 SoapUI 的下载量已经超过了100万次,成为了Web服务测试标准和领先的 Web 服务测试工具。

它不仅仅可以测试基于SOAP的Web 服务,也可以测试REST风格的 Web服务,后者也是本文介绍的重点。

SoapUI基于Java开发,支持多个平台,安装非常简单。

读者可以到 SoapUI2 SoapUI使用过程创建/导入工程安装并运行SoapUI之后,你就可以创建第一个SoapUI工程了。

程序第一次打开时,左侧导航面板上,自动有一个空的Projects工程。

右击左侧导航面板中的工作空间节点“Projects”,选择“New SoapUI Project”。

图表 2-1页面弹出“New SoapUI Project”TAB页,填入Project Name,Initial WSDL/WADL可填入URL地址或直接导入WSDL文件,导入文件后,如下图所示:图表 2-2默认选上:Create sample requests for all operations(说明:为每个接口创建一个请求的例子)Creates a TestSuite for the imported WSDL or WADL(说明:为WSDL或WADL创建一个测试包)点击OK按钮后,页面弹出保存工程的提示,以project名称+“- ”的形式进行命名,因此上述工程在保存时页面给出默认命名为,直接点击保存即可。

保存成功后,页面继续弹出“Generate TestSuite”TAB页:图表 2-3选择:Single TestCase with one Request for each Operation(说明:为每个接口的请求都创建一个测试用例)Create new empty requests(说明:创建一个空的请求)Operations中选择要测试的WS接口方法,如果一个WS有多个方法,Operations中会列出所有方法,只须选择要测试的方法即可,上图,去掉了test10、test2等接口的测试。

最后勾选上Generates a default LoadTest for each created TestCase(说明:为每个创建好的测试用例生成一个默认的负载测试)选择完毕后,点击OK按钮,进入测试用例命名页面,命名完毕后,确定。

图表 2-4在测试用例编写完毕后,可使用ctrl+s键,保存当前的工程。

如果要导入其他人的工程,可通过选择“Import Project”,找到,选中后即可导入工程。

创建测试用例上面操作已经增加了test1的Web服务,接下来可以执行请求了。

在上面增加接口的时候,已经根据WSDL的Schema定义为每一个操作创建了默认请求。

图表 2-5在RequestServiceSoapBinding节点下展开了WS服务中所有的方法,而我们的测试包test1_file_TestSuite中根据“创建、导入工程”的第4步,而仅创建了我们要测试的方法的测试用例。

现在将以测试test1方法为例,来介绍用例的创建过程。

按照下图所示,打下测试包下的“test1 TestCase”,在展开的“Test Steps”下选择“test1”,双击打开。

图表 2-6双击“test1”后,在SoapUI的右侧会出现请求编辑器:图表 2-7请求编辑器分为三部分:1.顶部的工具栏,包含一组请求相关的动作、操作2.左边是请求区域3.右边是响应区域SoapUI默认生成的请求中,””表示需要被替换的内容。

根据需要,可以替换或者删除掉这些值。

本接口需要一个名为id的入参,可在请求区域找到如下内容:<id xsi:type="soapenc:string"通过按下工具栏最左边的按钮(绿色箭头)来发送本次请求,请求会在后台执行,响应内容会出现在编辑器的右边,test1方法没有任何逻辑,任意的入参均不会影响到输出结果,出参为一个一维数组,第一个值为123,第二个值为456。

根据上述返回的结果报文后,可看到接口已被正确的调用,为在测试中不用人为地进行接口功能是否正确的判断,因此加入断言Assertions,可由程序直接对返回结果进行判断。

点击下图左上角的增加断言按钮:图表 2-8会弹出“Select Assertion”对话框,通过下拉框选择“Contains”的断言,确定后弹出如下对话框,在Content中填入内容,此处是表示返回的结果报文里应该包含的字段,根据我们test1接口的返回值,填写如下,点击“OK”,插入断言完毕,程序会在运行用例时,自动帮我们校验返回的结果报文是否包含“123”内容。

图表 2-9说明:“Test Steps”中可创建多个测试用例,组成一个测试用例集,在运行该test steps 时,会根据用例的顺序从上到下将用例进行一次测试,将上一用例的输出作为下一用例的输入再组织相应的用例,此处待进一步研究。

创建负载测试性能测试一般使用loadrunner,或者自己写的调用客户端进行测试。

loadrunner是全面的性能测试工具,对一般开发人员来说太重,并且需要license。

自己写调用的客户端则测试的统计数据也需要写程序处理,比较麻烦。

这里推荐使用SoapUI,SOAPUI可以直接根据WSDL生成SOAP数据包,手工填入参数后可以直接进行性能测试。

在创建完测试用例后,本工程的负载脚本也由在最初创建好工程时,已经默认创建完毕,在此可直接打开使用,如下,可直接点开Load Tests节点,节点下包含名称为“LoadTest1”的负载脚本,双击打开。

图表 2-10双击打开后,页面如下显示,设置过程参考如下,场景为100用户并发,持续运行10分钟,没有思考时间。

相应的SoapUI可设置Threads=100,Test Delay=0,Limit=600,后面的下拉框选择Seconds,表示600秒。

设置完毕后,点击左上方的绿色箭头,程序开始进行负载测试。

图表 2-11负载测试过程中,右上方会有进度条显示测试的进度情况,SoapUI提供了2个图表和一个简要列表的形式列出了测试过程中相关数据的监控,如下图,下图为简要列表形式提供的数据:图表 2-12点击上方红色方框框住的按钮,会弹出下方的监控图表,图中只有曲线,没有任何数据说明,只能看到变化的情况,由于无相应的刻度,而无法直观地看出数据大小:图表 2-13SoapUI还提供了另一个图表,此图表与上与图表类似,不过仅能显示线程数与另一统计内容的曲线变化情况,另一统计内容可通过下图红色方框里的“select statistic”进行选择,如下:图表 2-143与LoadRunner的比较使用LoadRunner提供的Webservice协议进行相同接口的测试。

不加校验的脚本(脚本名称:LR_1 )如下://@oolong 2/2/2010Action(){lr_start_transaction("here_start");web_service_call( "StepName=test1_101","ResponseParam=response","WSDL=C:/Documents and Settings/Owner/桌面/","UseWSDLCopy=1",BEGIN_ARGUMENTS,"xml:sss=<sss><string></string></sss>","id=aff",END_ARGUMENTS,BEGIN_RESULT,END_RESULT,LAST);lr_end_transaction("here_start", LR_AUTO);return 0;}加了校验的脚本(脚本名称:LR_2 )如下,下面的脚本提供了对返回结果的一个校验,类似SoapUI里提供的断言:Action(){char com[] = "123";lr_start_transaction("here_start");web_service_call( "StepName=test1_101","ResponseParam=response","WSDL=C:/Documents and Settings/Owner/桌面/","UseWSDLCopy=1",BEGIN_ARGUMENTS,"xml:sss=<sss><string></string></sss>","id=aff",END_ARGUMENTS,BEGIN_RESULT,"test1Return[1]=Param_result",END_RESULT,LAST);if(strcmp(lr_eval_string("{Param_result}"),com)==0){lr_end_transaction("here_start", LR_AUTO);lr_vuser_status_message("成功");}else{lr_end_transaction("here_start", LR_FAIL);lr_error_message(lr_eval_string("{Param_result}"));}return 0;}场景与SoapUI的场景一致:100用户并发,持续运行10分钟,没有思考时间。

对LR_2脚本进行性能测试后,发现响应时间比使用SoapUI进行测试的响应时间来的大,因此把校验过程注释掉,使用LR_1,又进行了一次负载测试。

相关文档
最新文档