SoapUI: The World's Most Popular API Testing Tool

官网地址:https://www.soapui.org/

 

 

 

 

 https://en.wikipedia.org/wiki/SoapUI

 

SoapUI is an open-source web service testing application for Simple Object Access Protocol (SOAP) and representational state transfers (REST). Its functionality covers web service inspection, invoking, development, simulation and mocking, functional testing, load and compliance testing. A commercial version, ReadyAPI (formerly SoapUI Pro), which mainly focuses on features designed to enhance productivity, was also developed by Eviware Software AB. In 2011, SmartBear Software acquired Eviware.[3][4]

 

 

SoapUI[edit]

Core features include web services:[10]

  • inspection
  • invoking
  • development
  • simulation and mocking
  • functional, compliance and security testing

 

SoapUI Pro[edit]

SoapUI Pro is the commercial enterprise version. SoapUI Pro adds a number of productivity enhancements to the SoapUI core, which are designed to ease many recurring tasks when working with SoapUI.[10]

FeatureBenefitRead more
WSDL coverage Analyze request/response messages to see how well a WSDL contract is being tested/mocked/used. [2]
WSDL refactoring Automatically update requests/response/assertions when the underlying WSDL changes. [3]
Composite projects Work together in a team on your Web service testing projects. [4]
Requirements management Manage, import, and export project requirements and link them to test cases. [5]
Form-based request editor To ease the editing and understanding of request messages for both technical and non-technical users. [6]
Overview message viewer To get an overview of the corresponding response/mock-request/monitored message. [7]
Tree-based request/response editor To ease the navigation and understanding of larger messages. [8]
Table inspector To quickly give an overview of tabular message content.  
Schema inspector To ease inspection and debugging of message content.  
XML inspector To ease inspection and debugging of message content.  
Doc inspector To ease understanding of message content.  
DataSource TestStep To ease the creation of data-driven tests. [9]
DataSink TestStep Eases collection of data to be used in subsequent tests or for external reporting. [10]
DataGen TestStep To simplify comprehensive testing of complex interfaces. [11]
Property transfer wizards To ease the creation of complex test cases / message flows. [12]
XPath Assertion Wizards To ease the creation of XPath assertions for TestRequest and MockResponse steps. [13]
XPath Wizards Eases creation of XPath expressions in many situations. [14]
Integrated reporting To provide summaries of functional testing for tracking and governance. [15]
Groovy script library Eases reuse and scripting of complex scenarios. [16]
Tabbed desktop Eases desktop management with multiple editors. [17]
API Discovery Ability to create SoapUI tests based on captured HTTP traffic that was generated from user actions (e.g. from browsing a website) [18]

 

 

 

原文:https://www.cnblogs.com/hong-fithing/p/7591751.html

 

SoapUI简介

SoapUI是一个开源测试工具,通过soap/http来检查、调用、实现Web Service的功能/负载/符合性测试。该工具既可作为一个单独的测试软件使用,也可利用插件集成到Eclipse,maven2.X,Netbeans 和intellij中使用。

SoapUI是一个自由和开放源码的跨平台功能测试解决方案。通过一个易于使用的图形界面和企业级功能,SoapUI让您轻松, 快速创建和执行自动化功能、回归、合规和负载测试。在一个测试环境,SoapUI提供完整的测试覆盖,并支持所有的标准协议和技术。

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

SoapUI下载地址:https://www.soapui.org/,下载开源版SoapUI,SoapUI ProSoapUI的商业非开源版本

入门实例解析

使用的接口实例是中国电视节目表WEB服务

WSDL地址:http://www.webxml.com.cn/webservices/ChinaTVprogramWebService.asmx?wsdl 

Endpoint地址:http://ws.webxml.com.cn/webservices/ChinaTVprogramWebService.asmx

通过案例讲解,能够掌握以下几个方面的操作:

1.构建项目

2.运行单个请求

3.构建测试用例

4.接口之间传递参数

5.运行整个测试用例

构建项目

1.打开SoapUI软件>File>New SOAP Project,新建工程

2.填入工程名和WSDL地址,WSDL地址为:http://www.webxml.com.cn/webservices/ChinaTVprogramWebService.asmx?wsdl

构选上“Create Requests”项目会根据WSDL文件创建接口请求文件;构选上“Create TestSuite”就会给WSDL创建一个测试套件

3.点击OK后就已经创建好一个工程了,自动添加WSDL里面有的接口,根据Soap 的版本不同提供了两种接口,如下图所示:

接口业务:

getAreaDataSet:获得支持的省市(地区) 和分类电视列表
getTVstationDataSet:通过省市ID 或分类电视ID 获得电视台列表
getTVchannelDataSet :通过电视台ID 获得该电视台频道列表
getTVprogramDataSet : 通过频道ID 获得该频道节目列表

在此处需要注意的是:除getAreaDataSet接口不需要入参,最后三个接口是需要输入参数的,接口getTVstationDataSet的请求中“?”表示要入参,如下图所示:

若不入参,运行会出错,会出现如下所示错误信息:

运行单个请求

1.选择getAreaDataSet下的Request1,双击,点击运行按钮,就会出现右侧面板中的结果,获得到支持的省市(地区) 和分类电视列表,如下图所示:

2.选择getTVstationDataSet下的Request1,双击,把中间面板中的?替换成省市ID或分类电视ID18,点击运行按钮,就会出现右侧面板中的结果,获得电视台列表,如下图所示:

3.选择getTVchannelDataSet 下的Request1,双击,把中间面板中的?替换成电视台ID98,点击运行按钮,就会出现右侧面板中的结果,获得频道列表,如下图所示:

4.选择getTVprogramDataSet 下的Request1,双击,把中间面板中的?替换成频道ID292,点击运行按钮,就会出现右侧面板中的结果,获得该频道节目列表

构建测试用例

1.创建测试套件:选择项目“CTV”右键点击“New TestSuite”,可输入测试名,如下图所示

2.创建测试用例Test case,选择测试套件“TestSuite 1”右键点击“New TestCase”,如下图所示:

创建好之后,新建的TestCase中包含三个部分:

测试步骤:Test Steos
负载测试:Load Tests
安全测试:Security Tests

3.把请求添加到测试用例中:选择一个请求,然后右键点击“Add to TestCase”,然后在弹出窗口中选择我们刚才新建的"TestSuite 1"即可,如下图所示:

执行操作后,就已经创建好了一条测试用例,如下图所示:

4.运行测试:打开TestCase窗口,点击绿色运行按钮即可,绿色表示运行成功,运行结果在右面板下方,如下图所示:

5.增加检查点

①在测试步骤中打开服务求请求,如下图所示:

②点击+号,添加检查点,选择Recently used>Contains>Add,如下图所示:

③输入检查的内容,如下图所示:

④然后运行服务请求,在“Assertions”窗口中可以看到“Contains - VALID”说明检查点是有效的,如下图所示:

接口之间传递参数,组织测试步骤

getAreaDataSet:获得支持的省市(地区) 和分类电视列表
getTVstationDataSet:通过省市ID 或分类电视ID 获得电视台列表
getTVchannelDataSet :通过电视台ID 获得该电视台频道列表
getTVprogramDataSet : 通过频道ID 获得该频道节目列表

依次加入到TestCase 1 的测试步骤中去,然后组织测试步骤获取“湖南金鹰卡通”的节目列表

具体的测试步骤为:

①获得“湖南省”的分类ID “18 ”

②获取“湖南省”类别中的“湖南电视台”ID :“98 ”

③获取“湖南电视台”的频道“湖南金鹰卡通 ”ID :“292 ”

④获取“湖南金鹰卡通”频道的节目列表

1.先将请求依次添加到用例中,如下图所示:

2.添加入参操作,用于两个服务请求间的交互,如下图所示:

将服务请求getAreaDataSet 结果中的“湖南省”ID“18 ”作为服务请求getTVstationDataSet 入参

创建好之后,双击,弹出如下图所示界面,输入参数值:

右侧面板上部分中输入如下代码,//并不是注释,只是表相对路径,(getAreaDataSet 结果)

 
declare namespace diffgr="urn:schemas-microsoft-com:xml-diffgram-v1";
//diffgr:diffgram/Area/AreaList[22]/areaID[1]

右侧面板下部分中输入如下代码(getTVstationDataSet 入参)

 
declare namespace web="http://WebXml.com.cn/";
//web:getTVstationDataSet/web:theAreaID[1]

点击运行,即可看到是否成功,成功如下图所示:

 

获取上述代码的方法:

上半部分getAreaDataSet 结果获取:

下半部分getTVstationDataSet 入参获取:

其它两个交互方法一样,稍微更改即可

将服务请求getTVstationDataSet结果中的“湖南电视台”ID“98 ”作为服务请求getTVchannelDataSet入参

右侧面板上部分中输入如下代码(getTVstationDataSet 结果)

 
declare namespace diffgr="urn:schemas-microsoft-com:xml-diffgram-v1";
//diffgr:diffgram/Station/TvStation[5]/tvStationID[1]

右侧面板下部分中输入如下代码(getTVchannelDataSet 入参)

 
declare namespace web="http://WebXml.com.cn/";
//web:getTVchannelDataSet/web:theTVstationID[1]

获取上述代码的方法:

上半部分getTVstationDataSet结果获取:

下半部分getTVchannelDataSet入参获取:

 

将服务请求getTVchannelDataSet 结果中的“湖南金鹰卡通”ID“292 ”作为服务请求getTVprogramDataSet 入参

右侧面板上部分中输入如下代码(getTVchannelDataSet结果)

 
declare namespace diffgr="urn:schemas-microsoft-com:xml-diffgram-v1";
//diffgr:diffgram/Channe/TvChanne[4]/tvChannelID[1]

右侧面板下部分中输入如下代码(getTVprogramDataSet入参)

 
declare namespace web="http://WebXml.com.cn/";
//web:getTVprogramDateSet/web:theTVchannelID[1]

获取上述代码的方法:

上半部分getTVchannelDataSet结果获取:

下半部分getTVprogramDataSet入参获取:

运行测试

1.整个测试步骤设置好之后,打开“TestCase 1”运行测试,全部绿色表示测试通过,如下图所示:

2.在TestCase Log中还可以看到接口之间传递的参数值,如下图所示:

3.运行结束后,再打开接口请求,可以看到请求显示的就是所传递的值,如下图所示:

4.还可以在请求中设置检查点,来检查是否通过,检查点的设置方法已在构建测试用例中介绍

 

posted @ 2022-12-27 10:19  PanPan003  阅读(58)  评论(0编辑  收藏  举报