Forum Discussion

AndreW273SK's avatar
AndreW273SK
New Contributor
8 years ago

Running specific test step in SoapUI based on testSuite property

I am new to scripting and have an issues regarding SoapUI groovy script I could use help with.

 

I need a script that will let me run specific testStep in testCase based on value of testSuite property ('CC1' is name of property) with 5 possibilities. I guess switch/case could be used, but don't know how to write it properly.

I tried using this:

 

def CC1 = 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" );  
}

But doesn't run the desired step.

 

Can someone help me with this, please?

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Have you looked at "Conditional GoTo" test step?
    • AndreW273SK's avatar
      AndreW273SK
      New Contributor

      Conditional GoTo is not realy an option in this case, becasue it checks the response, and the property I need to check against is in request.

       

      Andrej

      • nmrao's avatar
        nmrao
        Champion Level 3
        Oh ok. So, what is the issue with script that you have (could not go thru it)?