Forum Discussion

BrianJ's avatar
14 years ago

SoapUI test step help

Hi,
I have just started using soapUI and loadUI to test web service calls into an API.
I am passing in a fixed telephone number in the url. All else in the url will remain the same.
Some of the things I want to do are:

1) Have a test step goto a file (.txt preferably) and fetch a different phone number
on each interation of the test step set.
2) Have a test step that fetches a group of phone numbers and issues a set of url's
with each having a different phone number and makes a batch request

Any help would be great

Brian

1 Reply

  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    Hello Brian,

    You can generate the url at run time. I am sure there is way to read .txt file, but i feel its easier to read this information from properties file. You can create groovy script to create the url at run time and pass that as a parameter to your target step. Below is a peice of groovy code that might be helpfull:


    def path = groovyUtils1.getProjectPath();
    def propFile = "\\phone.properties";
    FileInputStream read = new FileInputStream(path + propFile);
    Properties prop = new Properties();
    prop.load(read);

    def totalCount= Integer.parseInt(prop.getProperty("totalCount"));
    for (counter in 1..totaCount)
    {
    def url = "http:\\phone.number.com\phonenumber=";
    def ph = "Phone";
    ph = ph + counter;
    phnumber = prop.getProperty(ph);
    url = url + phnumber;
    // you can now pass this url to target property in your test case and call the test case from here itself
    }


    You can have your property file like this now and name it as phone.properties:

    totalCount = 5
    Phone1 = 123456789
    Phone2 = 123456788
    Phone3 = 123456787
    Phone4 = 123456786
    Phone5 = 123456785

    Hope this helps. Let me know if you need any thing else.

    Thanks,
    Deepesh Jain