1. 程式人生 > >SoapUI 測試Data Driven(資料驅動測試)

SoapUI 測試Data Driven(資料驅動測試)

1.1. Prereqs

In our example we have the following;
A Microsoft SQL Server database (db_author) instance with one table, tb_author. we’ll also see in the end how to do this with MySQL.
The Amazon.com Web Service
A settings file containing login data
All these can be gotten by downloading the Tutorial .zip.

1.2. Preparation

Step 1, The MS SQL Server
If you don’t have an installation of MS SQL, use the download links here or read on, this tutorial is useful for MySQL as well.
Step 2, The Driver
First we need a JDBC driver, you can get that here .
Then unzip the file and put the driver, named sqljdbc.jar, either in your JAVA HOME/lib/ext or in soapUI/jre/ lib/ (for example C:\Program Files\SmartBear\soapUI-Pro-4.5.1\jre\lib\ext).
If you have soapUI running, restart it so that it can reload all drivers.
Step 3, The database.
OK, we need a database, so let’s make something simple to illustrate the functionality.
As usual we’ll use the Amazon Web Services to illustrate the functionality.
tb_authorWe’ll make a database called db_author containing one table called tb_author.
This table contains two fields, one called index and one called author. Like seen here:
That is all we need, let’s start soapUI and get testing! : Preparation
All these can be gotten by downloading the Tutorial .zip.

  1. Data Driven Testing: Implementation
    Now when we have the database set up and a JDBC driver running, let’s get going with the Implementation.

2.1. Implementation

Let us first examine what we want to do:
Get an Amazon User ID from a configuration file
Retrieve an Author from a MS SQL Database
Call Amazons ItemSearch with the User ID and Author
Handle the Response in some way
Loop until done
All thiz is in the Tutorial .zip.

2.1.1. Step o: Start the project

First we create a project
add_to_testcasefrom the URL http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl. In this we’ll choose the itemSearch request and add this to a TestCase.
We can then trim the request down to containing what we want.

2.1.2. Step 1: Get your ID

Now we have to populate the request with data and the first step is populating the element . (Note, if you don’t have a subscription ID for Amazon Web Services, get it now). We get the data by using a configuration file containing just one line;

and retrieving this in a PropertiesStep. We also have a second property, resultCount, which we’ll use later, more about this later, and a Property named type referring to the type of search we’re doing, i.e. books.

2.1.3. Step 2: Connecting to MS SQL

Driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
Connection String: jdbc:sqlserver://localhost:1898;databaseName=db_Author;user=eviware;password=eviware;
SQL Query: SELECT * FROM tb_Author
Let’s go on to actually populating the request and get to the heart of this tutorial. Let’s add a datasource.
insert_datasource
Then we configure the data source, here are the parameters:
Please note that you will have to change port, user and password to what you might have in your environment.
We also will have to add two properties, index and author that corresponds to the SQL Statement. Once done, you can test the entire step.
datasourcestep

2.1.4. Step 3: DataTransfer

Now that we have collected the data, let’s transfer it into the request.

Let’s add a PropertyTransfer Step with three transfers, MoveAuthor, MoveMyID, MoveType.We can use the XPath Selector tool to make the transfer a breeze.
propertytransfer_step

We have made a small movie showing this step. Watch it here (in a new window)

2.1.5. Step 4: Check the test

What we have now should look like this.
Gotten base parameters
Gotten Test Data
Transferred into a search
The Search Request
like this:
so_far

2.1.6. Step 5: Using the result

Remember we had a property called resultcount, let’s use it. We make another property transfer step that takes the number of hits from the ItemSearch response and moves it to the property, remember to use the xpath selector. Also remember that you have to run the request in order to be able to use the selector, without a proper request you won’t have a proper response to choose from.
response_transfer

2.1.7. Step 6: A Groovy Step

In order to see that this is working, let’s show a dialog with the result. We add a Groovy script containing the following;
// get target step
def step = testRunner.testCase.getTestStepByName( “My ID” );
def step2 = testRunner.testCase.getTestStepByName( “MySQL Retrieve” );
com.eviware.soapui.support.UISupport.showInfoMessage(
“Got ” + step.getPropertyValue( “ResultCount” ) + ” hits for author [” +
step2.getPropertyValue( “Author” ) + “]” );

2.1.8. Step 7: Loop it!

Lastly, in order to use all data in the database, we need to finish the test with a DataSourceLoop step.
datasourceloop

Now we can run the entire test, and should be receiving the following:
therun

And that is it! You now have a working test! Creating a data driven test in soapUI isn’t harder than that.

But wait! What about MySQL users? Well basically it’s the same thing, all you need to do is change the DataSourceStep to the following:

Driver: com.mysql.jdbc.Driver
Connection String: jdbc:mysql://localhost:3306/eviware_demo_datainsert?user=evidemo&password=evipass
SQL Query: SELECT * FROM tb_Author
Both MySQL and MS SQL projects are available to Pro Users.

Project Files and More coming up!

相關推薦

SoapUI 測試Data Driven資料驅動測試

1.1. Prereqs In our example we have the following; A Microsoft SQL Server database (db_author) instance with one table, tb_au

.netcore持續整合測試篇之Xunit資料驅動測試

>[系列目錄](https://www.cnblogs.com/tylerzhou/p/11204826.html) Nunit裡提供了豐富的資料測試功能,雖然Xunit裡提供的比較少,但是也能滿足很多場景下使用了,如果資料場景非常複雜,Nunit和Xunit都是無法勝任的,有不少測試者選擇自己編寫一個

Android Data Binding資料繫結使用者指南

轉自:https://www.jianshu.com/p/b1df61a4df77 1. 介紹 這篇文章介紹瞭如何使用Data Binding庫來寫宣告的layouts檔案,並且用最少的程式碼來繫結你的app邏輯和layouts檔案。Data Binding庫不僅靈活而且廣泛相容-

扒一扒資料驅動測試DDT與關鍵字驅動測試KDT

帶軟體功能測試專案的過程中,發現很多人對這兩個概念很困惑,並且試圖通過圈定KDT與DDT的各自邊界來分離它們,結果糾結成了一團麻線。我們從它們的名稱及說明來理一理。 KDT(Keyword-drive

Web測試到底是在測什麼資料合集

https://www.cnblogs.com/idotest/p/6838583.html     圖片略模糊 看得清就好   Web測試, 進行抽離拆分,基本上就如上一些內容。 不管是測什麼系統,什麼功能,基本都差不多。 唯一區別是,一些特性 &

SVG_text.文字高度ascent&baseline&descent資料測試

ZC:文字的 高度的測試在文章的後半部分   1、html5 svg 第八章 文字text - 2030的專欄 - CSDN部落格.html(https://blog.csdn.net/lcy132100/article/details/9722543)      2、baseline-sh

python - 資料驅動測試 - ddt

# -*- coding:utf-8 -*- ''' @project: jiaxy @author: Jimmy @file: study_ddt.py @ide: PyCharm Community Edition @time: 2018-12-06 14:48 @blog: https://ww

python-ddt 資料驅動測試

1 # @File : learn_ddt.py 2 3 #-*- coding:utf-8 -*- 4 5 #本次學習:ddt ---data drive test--資料驅動測試 6 #1.安裝 pip install ddt 7 #2.用途:結合單元測試去執行用例 8 #3.

python--DDT資料驅動測試

1、前言   在做介面測試或UI測試時經常會出現多個用例僅輸入引數不同,操作過程完全相同(如登入,新建客戶等等),重複編寫用例不僅增加了程式碼量而且不好維護,引入DDT(Data-Driven Tests)資料驅動測試可實現引數化,DDt允許您使用不同的測試資料執行一個測試用例,並使它作為多個測試用例出現。

Python ddt 資料驅動測試

原文:https://www.cnblogs.com/hellowcf/p/6962935.html 為了記錄筆記所以轉載下 下載ddt並安裝 Pip install ddt 或者官網下載安裝 DDT的使用 DDT包含類的裝飾器ddt和兩個方法裝飾

資料驅動測試例項

1、讀取txt檔案 # 讀取資料檔案 # 開啟 user_file = open('user_info.txt', 'r') # 讀取多行 lines = user_file.readlines()

資料驅動測試三:使用TestNG、Apache POI和Excel檔案進行資料驅動

一、測試環境準備 1、從http://www.apache.org/dyn/closer.cgi/poi/release/bin/poi-bin/poi-bin-3.14.zip下載POI的壓縮包檔案。 2、將壓縮包進行解壓,將解壓檔案根目錄下的JAR檔案和ooxml-li

資料驅動測試二:使用TestNG和CSV檔案進行資料驅動

使用@DataProvider註解定義當前方法中的返回物件CSV檔案(存放測試資料)作為測試指令碼的測試資料集進行資料驅動。 用法參考程式碼: 程式碼在搜尋完成後使用顯式等待方式,確認頁面已經載入完成,頁面底部的關鍵字"搜尋幫助"已經顯示在頁面上 //從CSV檔案中讀取每行

selenium+python3-資料驅動測試示例

資料驅動的形式有很多種, 既可以通過定義變數的方式進行引數化,也可以通過定義陣列、字典的方式進行引數化,還可以通過讀取檔案 (txt、csv\xml)的方式進行引數化。 同樣以郵箱登陸為例,但 需求是測試不同的使用者登陸。不變的是登陸步驟,變化的是每次登

【python介面自動化】- DDT資料驅動測試

# 簡單介紹 ​ DDT(Date Driver Test),所謂資料驅動測試,簡單來說就是由資料的改變從而驅動自動化測試的執行,最終引起測試結果的改變。通過使用資料驅動測試的方法,可以在需要驗證多組資料測試場景中,使用外部資料來源實現對輸入輸出與期望值的引數化,避免在測試中使用硬編碼的資料,也就是測試資

api-gateway實踐8新服務網關 - 測試發布服務端API

isp logs rest span com 點擊 功能 size json對象 一、網關引擎 網關引擎地址:http://10.110.20.191:8080/api-gateway-engine/ 二、服務提供者 服務提供者地址:http://10.110.20.19

手機自動化測試環境搭建eclipse+python+uiautomator

list fig finish java環境 pda 所有 開發 界面 自己 最近在公司做了一個階段的手機APP自動化測試,是在已有的環境基礎上進行腳本開發,所有對基礎的環境搭建不是很清楚,後來自己閑來無事就在家裏搭建了一下下,接下來和大家分享一下搭建過程。 一:搭建手機A

Appium之編寫H5應用測試腳本切換到Webview

源碼 ttext med 上下文 測試 elements except 127.0.0.1 code App使用H5編寫,默認方式找不到元素。啟動後獲取所有上下文,找到webivew_xxxx的,然後進行切換。 源碼: 1 package MyAppium; 2

介面測試總結分享http與rpc

    介面測試是測試系統元件間介面的一種測試。介面測試主要用於檢測外部系統與系統之間以及內部各個子系統之間的互動點。測試的重點是要檢查資料的交換,傳遞和控制管理過程,以及系統間的相互邏輯依賴關係等。   一、瞭解一下HTTP與RPC   1. HTTP(HyperText T

Jmeter效能測試工具學習7.引數化

引數化 — 對於動態變化的值引入引數化會變得更加便捷   現實考慮 哪些地方需要引數化?   引數化需要變數 變數新增方式 1、在Test Plan中新增 變數 2、在UDV中新增變數 3、在foreach中新增隨機變數 &