Groovy 如何在SoapUI测试用例中忽略某些测试步骤错误? 目标
我希望“常规”测试步骤能够破坏SoapUI测试用例,而测试步骤的一个子集应被允许失败 根本原因 我有一个SoapUI测试用例,它执行一个相当复杂的功能测试,其中一些可选的细节由额外的JDBC测试步骤检查。因为这些细节是“可选的”,所以即使一个或多个JDBC测试失败,测试用例也不应该失败(即它应该变成绿色) 快到了 如果要求允许测试用例中的所有测试步骤失败,我可以简单地切换测试用例行为: 打开TestCase选项对话框(从TestCase工具栏),取消选中错误时中止选项。当您运行TestCase时,该步骤仍然失败,但SoapUI将继续运行其他测试步骤 问题:Groovy 如何在SoapUI测试用例中忽略某些测试步骤错误? 目标,groovy,integration-testing,soapui,Groovy,Integration Testing,Soapui,我希望“常规”测试步骤能够破坏SoapUI测试用例,而测试步骤的一个子集应被允许失败 根本原因 我有一个SoapUI测试用例,它执行一个相当复杂的功能测试,其中一些可选的细节由额外的JDBC测试步骤检查。因为这些细节是“可选的”,所以即使一个或多个JDBC测试失败,测试用例也不应该失败(即它应该变成绿色) 快到了 如果要求允许测试用例中的所有测试步骤失败,我可以简单地切换测试用例行为: 打开TestCase选项对话框(从TestCase工具栏),取消选中错误时中止选项。当您运行TestCase时
- 通过测试步骤级别的设置或属性(特别是:没有Pro版本)可以实现此目标吗
- 在
的测试步骤级别上,是否有类似于WsdlTestCase
/setFailOnError
方法的Groovy解决方案setfailtestcaseonerror
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}."
}
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."
}
之后:restoreFailOnErrorBehavior.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}."
}
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."
}
这些脚本依赖两种方法来更改测试用例行为:
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}."
}
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."
}
之后:restoreFailOnErrorBehavior.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}."
}
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."
}
这些脚本依赖两种方法来更改测试用例行为:
- 右键单击测试用例
选择选项;在“基本”选项卡下-- 取消选择错误时中止[如果选中] - 右键单击测试用例
选择选项;在“基本”选项卡下-- 取消选择错误时中止[如果选中]
\u failOnError
和\u failtestcaseonerror
仅用于存储测试用例的当前状态,以便我们可以在之后恢复初始行为。这些脚本的核心功能在于调用TestCase对象上的setFailOnError()
和setfailtestcaseonerror()
。i、 不要依赖属性,因为它们不会更新,例如,如果您手动更改TestCase行为(选项对话框)。我尝试了这个方法,但它对我不起作用。我已经在groovy脚本中添加了第一个代码。我可以看到在testcase级别设置的2个属性。。当我运行testcase时,由于一些预期的功能问题,该步骤失败,即使设置了这两个属性,执行也会停止。下一步应该已经运行了,因为属性已经在testcase中设置好了level@Gauravkhurana属性\u failOnError
和\u failtestcaseonerror
仅用于存储测试用例的当前状态,以便我们可以在之后恢复初始行为。这些脚本的核心功能在于调用TestCase对象上的setFailOnError()
和setfailtestcaseonerror()
。i、 e.不要依赖属性,因为它们不会更新,例如,如果您手动更改TestCase行为(选项对话框)。