【发布时间】:2017-01-06 18:47:41
【问题描述】:
我是脚本新手,需要一些帮助。我有一个关于 SoapUI groovy 脚本的问题,我可以使用帮助。
我需要一个脚本,它可以让我根据 testSuite 属性的值('CC1' 是属性的名称)在 testCase 中运行特定的 testStep,有 5 种可能性。我猜可以使用switch/case,但不知道如何正确写。
目前我尝试使用这个:
def CC1 = testRunner.testCase.testSuite.getPropertyValue("CC1")
log.info testRunner.testCase.testSuite.getPropertyValue("CC1")
switch(CC1)
{
case ~/^[H1]+$/: testRunner.runTestStepByName( "PT02_H1" ); break;
case ~/^[Y5]+$/: testRunner.runTestStepByName( "PT02_Y5" ); break;
case ~/^[Q2]+$/: testRunner.runTestStepByName( "PT02_Q2" ); break;
case ~/^[T5]+$/: testRunner.runTestStepByName( "PT02_T5" ); break;
default : testRunner.runTestStepByName( "PT02_AQ" );
}
但没有运行所需的步骤。
有人可以帮我解决这个问题吗?
【问题讨论】:
-
为什么两个问题合二为一?
-
我为一个问题编辑了帖子。
-
你的测试用例是什么样的?上述 groovy 脚本和其他 5 个测试步骤(您想要执行其中一个)是否在同一个测试用例中?你看过
Conditional goto测试步骤吗?