Forum Discussion

ripplegupta's avatar
ripplegupta
Contributor
8 years ago
Solved

How to update description property of a test step via groovy

How to update description property of a test step via groovy.

 

Each test step has description , how can i update it via groovy ?

  • KarelHusa's avatar
    KarelHusa
    8 years ago

    You are right. The REST test step behaviour seems to be different than other types of steps.

     

    See the following code, it's rather a workaround, but it does the job.

     

    context.testCase.getTestStepList().each {
    	def desc = 'New description - TEST'
    	def step = it
    	step.setDescription(desc)
    	if (step.getDescription() != desc) {
    		// here we come with REST test step
    		log.info step.getName() + ":" + step.getDescription()
    		step.getTestRequest().setDescription('Another description')
    	}
    }

7 Replies

  • KarelHusa's avatar
    KarelHusa
    Champion Level 3

    You just do it: 

     

    step.setDescription('The description')

    You can loop through all test steps, e.g. this way:

     

    context.testCase.getTestStepList().each {
    	def step = it
    	step.setDescription('This is my description')
    }

     

    You can look at API docs for more. The SoapUI objects are derived from the ModelItem and it's implementations, so a lot of API is common for steps, test cases, suites and others.

     

    • ripplegupta's avatar
      ripplegupta
      Contributor

      Hi KarelHusa,

       

      Thanks for answering (I was searching docs and didn't find setDescription, thanks for letting me know.)

       

      I used below code in one of the groovy step but its only updating description of that groovy step not of all steps in that test case.

       

      I will try but if you can let me know what's wrong here..

       

      thanks..

      • KarelHusa's avatar
        KarelHusa
        Champion Level 3

        The script updates all test steps belonging to the current test case. 

         

        I can recommend to add logging into the loop, e.g. start with:

         

        log.info step.getName()

        If you get stuck, feel free to post the script and a screenshot of your test case/test steps.