您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 >
用SoapUI進(jìn)行Webservice的性能壓力測試
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時間:[ 2013/4/16 15:36:27 ] 推薦標(biāo)簽:

  1. 新建測試工程

  選擇在一個測試用例中測試多個方法,并為測試生成壓力測試:

  2. 為測試 Step 添加變量:

  右鍵選中 Test Step ,添加一個 Grooy Script Step ;添加一個變量 count 并設(shè)置初始值為 0

  3. 添加一個隨機(jī)變量:

  右鍵選中 Test Step ,添加一個 Grooy Script Step ;名稱為 rand ,用下面的代碼產(chǎn)生一個隨機(jī)值

  view plaincopy to clipboardprint?

  01.Random rand = new Random()

  02.result = "test_" + rand.nextInt(100)

  Random rand = new Random()

  result = "test_" + rand.nextInt(100)

  4. 使用動態(tài)參數(shù):

  打開 init 操作的 SOAP 請求,將輸入?yún)?shù)用上面步驟產(chǎn)生的隨機(jī)替換

  view plaincopy to clipboardprint?

  http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.test.jastar.com.cn">

  ${rand#result}

  http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.test.jastar.com.cn">

  ${rand#result}

  5. 按條件選擇執(zhí)行操作:

  同樣的再添加一個 Grooy Script Step ;名稱叫 ExecHandler ,用來條件控制用例的執(zhí)行

  view plaincopy to clipboardprint?

  01.def countProps = testRunner.testCase.getTestStepByName("count")

  02.def index = countProps.getPropertyValue("count")

  03.if (index == "0") {

  04. testRunner.runTestStepByName("init")

  05.} else {

  06. testRunner.runTestStepByName("run")

  07.}

  08.countProps.setPropertyValue("count", "1")

  def countProps = testRunner.testCase.getTestStepByName("count")

  def index = countProps.getPropertyValue("count")

  if (index == "0") {

  testRunner.runTestStepByName("init")

  } else {

  testRunner.runTestStepByName("run")

  }

  countProps.setPropertyValue("count", "1")

  6. 執(zhí)行測試:

  打開 LoadTest , disable 掉 init 和 run(ExecHandler 控制 init 和 run 的執(zhí)行 ) ,設(shè)置好參數(shù), OK 可以開始跑了。正如你所預(yù)期的 init 方法只執(zhí)行一次,而 run 將會按照你所設(shè)置的方式來執(zhí)行。

軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd