1

I am using Soap UI to test the RESTFul webservices.. I have stored [1,2,3,4,5....,10] in the property as PassedValue.. i have to convert this value as Array or list..so that i can fetch each index value.

ExpectedValue = context.testCase.getPropertyValue("PassedValue") as String[] 

This is not working.. if I Print ExpectedValue[0] it prints "["

I wanted to extract ExpectedValue[0] as 1 and 1st index as 2.. .

tried to convert as .toList but still no luck..

Can any one help me out on this?

Paxic
  • 1,760
  • 16
  • 28
ChanGan
  • 4,254
  • 11
  • 74
  • 135

2 Answers2

5

You could use Eval

For instance;

def expectedValue = Eval.me(context.testCase.getPropertyValue("PassedValue"))

For More Information Eval Class

dsharew
  • 10,377
  • 6
  • 49
  • 75
Gökhan Polat
  • 431
  • 4
  • 9
1

I liked @Gokhan's solution but am putting this as alternative solution.

You can use JsonSlurper to achieve the same thing:

import groovy.json.JsonSlurper;

def result = ​new JsonSlurper().parseText("[1,2,3]")

dsharew
  • 10,377
  • 6
  • 49
  • 75