如何根据测试用例结果在SoapUI中运行指定的步骤 [英] How to run specified step in SoapUI according testcase result

查看:172
本文介绍了如何根据测试用例结果在SoapUI中运行指定的步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在soapui中有更多测试用例的项目.在运行完每个测试用例之后,我需要运行两个http请求之一,具体取决于步骤的结果.因此,如果测试用例中的一个或多个步骤失败,则需要运行httprequest1,如果所有步骤都通过了,则需要运行httprequest2.我怎样才能做到这一点?我已经尝试了许多脚本...目前,我最好的解决方案是这样的,只需在测试用例的末尾添加groovy脚本即可.问题在于它仅检查最后一步.我尝试了许多其他解决方案,但没有任何工作对我有用.有人可以帮我吗?谢谢

I have project in soapui with more testcases. After running each testcase I need to run one of two http request, depending on results of steps. So if one or more steps in testcase failed, I need to run httprequest1 and if all steps passed I need to run httprequest2. How can I do this? I have tried many scripts... for now my best solution is something like this, just add groovy script at the end of test case. Problem is that it is checking only last step. I have tried many other solutions, but nothing was working for me. Can somebody help me with this? Thank you

def lastResult = testRunner.getResults().last()
def lastResultStatus = lastResult.getStatus().toString()

log.info 'Test  + lastResultStatus

if( lastResultStatus == 'FAILED' )
{

 testRunner.gotoStepByName( 'httprequest1' )
 testRunner.testCase.testSteps["httprequest2"].setDisabled(true)

}
else
{
 testRunner.gotoStepByName( 'httprequest2' )
}

我尝试过的另一种解决方案:

another solution that I have tried:

for( r in testRunner.results )
result = r.status.toString()
log.info result

if( result == 'FAILED' )
{
testRunner.gotoStepByName( 'httprequest1' )
testRunner.testCase.testSteps["httprequest2"].setDisabled(true)
}
else
{
testRunner.gotoStepByName( 'httprequest2' )
}

推荐答案

使用测试用例拆卸来调用该步骤,因为您必须对所有测试用例都执行此操作.拆卸脚本将如下所示:

Use a testcase teardown to call the step, since you have to do it for all test cases. The teardown script will look something like this:

if(testRunner.status.toString() == "FAILED"){
       testRunner.runTestStepByName( "httprequest1")
       println "in if"
}else{
     testRunner.runTestStepByName( "httprequest2")
     println "in else" 
}

请注意,您必须使用SoapUI Runner来触发测试用例/套件以及所调用方法的差异.

Note that you have to use the SoapUI Runner to trigger the testcase / suite and the difference in method being called.

这篇关于如何根据测试用例结果在SoapUI中运行指定的步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆