Groovy 基于testSuite属性在SoapUI中运行特定测试步骤

Groovy 基于testSuite属性在SoapUI中运行特定测试步骤,groovy,soapui,Groovy,Soapui,我不熟悉脚本,需要一些帮助。我有一个关于SoapUI groovy脚本的问题需要帮助 我需要一个脚本,可以让我基于testSuite属性的值(“CC1”是属性的名称)在testCase中运行特定的testStep,有5种可能。我想开关/箱子可以用,但我不知道如何正确书写 当时我试着用这个: def CC1 = testRunner.testCase.testSuite.getPropertyValue("CC1") log.info testRunner.testCase.testSuite.g

我不熟悉脚本,需要一些帮助。我有一个关于SoapUI groovy脚本的问题需要帮助

我需要一个脚本,可以让我基于testSuite属性的值(“CC1”是属性的名称)在testCase中运行特定的testStep,有5种可能。我想开关/箱子可以用,但我不知道如何正确书写

当时我试着用这个:

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" );  
}
但是没有运行所需的步骤

有人能帮我吗?

尝试以下脚本(从groovyTestStep运行):

尝试以下脚本(从groovyTestStep运行):


为什么两个问题合并成一个?我为一个问题编辑了我的帖子。你的测试用例看起来怎么样?上面的groovy脚本和您想要执行的其他5个测试步骤是否在同一个测试用例中?你看过
条件转到测试步骤吗?为什么两个问题合并成一个问题?我编辑了一个问题的帖子。你的测试用例看起来怎么样?上面的groovy脚本和您想要执行的其他5个测试步骤是否在同一个测试用例中?您是否看过
条件转到测试步骤?
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def testCase = testRunner.testCase;
def testStep = null;
def CC1 = testRunner.testCase.testSuite.getPropertyValue("CC1")
log.info testRunner.testCase.testSuite.getPropertyValue("CC1")

switch(CC1)  
{  
  case ~/^[H1]+$/: testStep = testCase.getTestStepByName( "PT02_H1" ); break;  
  case ~/^[Y5]+$/: testStep = testCase.getTestStepByName( "PT02_Y5" ); break;  
  case ~/^[Q2]+$/: testStep = testCase.getTestStepByName( "PT02_Q2" ); break;  
  case ~/^[T5]+$/: testStep = testCase.getTestStepByName( "PT02_T5" ); break;  
  default : testStep = testCase.getTestStepByName( "PT02_AQ" );  
}
testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null);
testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep);
testStep.run(testRunner, testStepContext);
log.info "TEST OK:"+testStep.getName();