SoapUI several common parameterization of

Today, we soapui this tool in several ways on the parameters of the specific application scenarios, and to sort out under

1、properties

The official document: https://www.soapui.org/docs/functional-testing/teststep-reference/properties.html

For example, the work that is needed to test the main flow features multiple functions, such as register here register, login login two feature requests, request parameters included, we look at are:

Registration Request parameters are the phone numbers mobilephone, password pwd, registered name regname

Login request parameters are the phone numbers mobilephone, password pwd

If you want to run multiple TestCase, complete multiple registrations - login because mobilephone, regname is unique, so each run once, it must be modified once these parameter values. The actual work can not only register, login two requests, feature requests will be more contained, the workload is quite large.

So this solution is parameterized


1)右键Test Steps-->Add Step-->Properties


2) Add two required parameters of the variable, the variable name custom were mobilephone, name; the corresponding value value required to fill in a registered user phone number and name information


3) for each register, login request parameter variable references. $ {Properties # mobilephone} fixed wording referenced variables $ {variable name}, Properties # mobilephone mobilephone represented Properties defined variables, $ {Properties # name} Similarly


4) Double-click to see the results TestCase run


2、DataSource

The official document: https://www.soapui.org/docs/data-driven-tests/reference/datasources.html

右键Test Steps-->Add Step-->DataSource


数据源类型

以上我们讲两种常用到的数据源类型

 

1)DataSource之Excel

a、例如我们需要批量注册多个用户,先准备包含多个注册用户信息的excel


b、DataSource中按照如下1、2、3步去添加并测试获取数据是否正确


c、右键Test Steps-->Add Step-->DataSource Loop, 添加在循环register请求之后。并且设置DataSource Loop的数据来源步骤、目标step是register


d、进行register请求中参数的变量引用


e、双击TestCase,运行查看结果循环4次


2)DataSource之JDBC

例如需要从数据库获取到用户账号信息完成登录,这里我们主要从数据库获取手机号码mobilephone


a、DataSource中数据源类型选择JDBC,并进行如下对应设置

设置完后测试下连接,成功。

测试不成功请注意:连接数据库需要用到驱动jar包,soapui本身不自带,需要自己下载后放到soapui安装目录的lib目录下。不同数据库驱动不一样。


b、在SQL Query中输入要查询的sql语句,select mobilephone from member order by id desc;

并且添加properties参数mobilephone,点击运行,能看到已经成功获取数据库的值


c、进行login请求中参数的变量引用


d、在login请求后右键Test Steps-->Add Step-->添加DataSource Loop,并设置Loop,目标step是login


e、双击TestCase,运行查看结果,循环36次获取到数据库的所有手机号并完成了登录


ps:若不想将获取到的所有数据完成循环,DataSource进行下数据读取设置


运行后,只循环5次

soapui的常用参数化方式就整理到这,希望大家学有所用

Guess you like

Origin www.cnblogs.com/tudou-22/p/11660191.html