Forum Discussion

SumitM's avatar
SumitM
Occasional Contributor
7 years ago

Creating groovy Test Steps dynamically from setup script in SoapUI Pro.

Hello,

 

Is it possible to create groovy Test steps from Setup script for all underlying Test cases in a perticular test suite?

 

I want to add a generic groovy code Test step in each Test case. If yes, can some one please share how we can achieve this.

 

Thanks, SumitM

  • Depending on what exactly you want to do, you could create a custom event to be run before each test case.

  • SiKing's avatar
    SiKing
    Community Expert

    Depending on what exactly you want to do, you could create a custom event to be run before each test case.

  • Vallalarasu_P's avatar
    Vallalarasu_P
    Frequent Contributor

    Writing a Script to manage an Excel where the Flag (Yes/No) can decide on execution of the Test cases/Test Steps under Test Suite. 

     

    Refer to my youtube video which I created for the same. SOAPUI Framework

    • SumitM's avatar
      SumitM
      Occasional Contributor

      Hello Vallalarasu_P,

       

      Maybe I am not very clear in my issue. Appologies from my end.

       

      Actually I need to create groovy Test steps in my Test cases dynamically (on the go).

       

      The Test cases I am running now, do not have a perticular function, which is needed to execute. So I need to add 

       

      a groovy Test Step to execute some groovy codes. I can manually add the groovy Test Step in each test case and

       

      run my test suite. But, manually adding test step is taking too much of my effort. So i was wondering that if I can 

       

      a groovy code in my Startup script, which will in turn add groovy Test steps in all my Test cases. if this scenario is

       

      possible, then can someone please share how to achieve this.

       

      Thanks, 

      SumitM

  • Vallalarasu_P's avatar
    Vallalarasu_P
    Frequent Contributor

    Adding New TestSuite
    def suite = context.testCase.testSuite.project.addNewTestSuite("AutomatedTestSuite")

    Adding New TestCase
    def tc = suite.addNewTestCase("automatedTestCase")

    // get a Test Step
    def project = context.testCase.testSuite.project

    Defining the Test Step for the Suite,Testcase and TestStep
    def testStep = project.testSuites['TestSuiteName'].testCases['TestCaseName'].testSteps['testStepName']
    // add it to your new generated testCase
    tc.cloneStep(testStep,testStep.name + "_Copy")

     

    Hope this helps