簡體   English   中英

如何忽略SoapUI測試用例中的某些測試步驟錯誤?

[英]How to ignore certain test step errors in SoapUI test case?

目標

我想要“常規”測試步驟來打破SoapUI測試用例,同時應該允許 測試步驟的一個不同子集 失敗

合理

我有一個SoapUI測試用例,它執行相當復雜的功能測試,其中一些可選的詳細信息通過其他JDBC測試步驟進行檢查。 由於這些細節是“可選的”,即使這些JDBC測試中的一個或多個失敗,測試用例也不會失敗(即它應該變為綠色)。

快好了

如果要求允許測試用例中的所有測試步驟失敗,我可以簡單地切換測試用例行為:

打開TestCase Options對話框(從TestCase工具欄中)並取消選中Abort on Error選項。 當您運行TestCase時,該步驟仍然失敗,但SoapUI將繼續運行其他TestSteps 功能測試| 數據驅動測試(SoapUI.org)

  • 這個目標可以通過測試步驟級別的設置或屬性來實現(特別是:沒有Pro版本)?
  • 是否有一個Groovy解決類似setFailOnError / setFailTestCaseOnErrors上的方法WsdlTestCase但測試步驟的水平?

我通過插入兩個Groovy測試步驟來解決它

  1. 將當前測試用例設置存儲在(臨時)測試用例自定義屬性字段中;
  2. 在可選步驟之前轉動錯誤行為;
  3. 從(臨時)屬性中的可選步驟之后恢復先前的錯誤行為。

之前: disableFailOnErrorBehavior.groovy

testRunner.testCase.with {
    // Store current TestCase options in (temporary) TestCase properties.
    setPropertyValue('_failOnError', failOnError.toString())
    setPropertyValue('_failTestCaseOnErrors', failTestCaseOnErrors.toString())
    log.debug "Saved FailOnError behavior: ${failOnError}, ${failTestCaseOnErrors}."

    // Allow following TestSteps to fail without aborting the TestCase immediately.
    setFailOnError(false)
    setFailTestCaseOnErrors(true)
    log.info "Set FailOnError behavior: ${failOnError}, ${failTestCaseOnErrors}."
}

之后: restoreFailOnErrorBehavior.groovy

testRunner.testCase.with{
    // Use (temporary) TestCase properties to restore initial TestCase options.
    setFailOnError(getPropertyValue('_failOnError').toBoolean())
    setFailTestCaseOnErrors(getPropertyValue('_failTestCaseOnErrors').toBoolean())
    log.info "Restored FailOnError behavior: ${failOnError}, ${failTestCaseOnErrors}."

    // Remove (temporary) TestCase properties.
    removeProperty('_failOnError')
    removeProperty('_failTestCaseOnErrors')
    log.debug "Clean up temporary properties: done."
}

這些腳本依賴於兩種方法來更改測試用例行為:

  • 右鍵單擊測試用例;
    選擇選項; 在基本選項卡下 - 取消選擇錯誤中止[如果選中]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM