如何使用Groovy脚本启用/禁用soapUI中的测试步骤(在每个测试用例中)根据用户想要启用或禁用的测试步骤。
喜欢:
请在下面找到抛出错误的样本:
Sat May 20 11:35:14 CEST 2017:ERROR:An error occurred [java.lang.NullPointerException], see error log for details while executing the next test cases.
代码:
context.testCase.testSuite.getTestCaseList().each
{
log.info "Test Case : ${it.name}".toUpperCase();
it.testStepList.each
{
log.info "Test Step--> : ${it.name}"
def testStep = testRunner.testCase.getTestStepByName( "${it.name}"
log.info testStep.disabled
if( testStep.disabled )
{
testStep.disabled = false
}
testRunner.testCase.getTestStepByName("${it.name}").setDisabled(true)
log.info testStep.disabled
log.info "Action Perfomed for Test Step : ${it.name}"
}
}
答案 0 :(得分:0)
在您的代码示例中,
def testStep = testRunner.testCase.getTestStepByName( "${it.name}"
是不必要的。它在testSuite中查找一个带有特殊名称的testStep,其中包含您运行的脚本,但不会出现NullPointer异常。
它可以简单地替换为'
context.testCase.testSuite.getTestCaseList().each
{
log.info "Test Case : ${it.name}".toUpperCase();
it.testStepList.each
{
log.info "Test Step--> : ${it.name}"
log.info it.disabled
if( it.disabled )
{
it.disabled = false
}
it.setDisabled(true)
log.info it.disabled
log.info "Action Perfomed for Test Step : ${it.name}"
}
}