Forum Discussion

Towelie's avatar
Towelie
Occasional Visitor
9 years ago

Validating a randomly generated name

Hello,

I am tottaly new to Soap UI. I got a task to make a project, that would create a test project in my Testlink. The test project should always have a different name, so that there would be no chance of deleting the previous one. My idea was to give the project the name TestProject# and the number would be randomly generated.

Like this:

TestProject#${=(int)(Math.random() * 90000 + 10000)}

the thing is that I have no knowledge of how to validate if the name already exists. The project I got requests it simply like this:

<member>
     <name>testprojectname</name>
      <value>
		<string>${#Project#projectName}</string>
      </value>
</member>

But this makes it generate the number again, so the name doesn't match and the validation obviously can't pass.
So the question is, how can I make the validation pass or if there is some different method that would generate the project name.

Thank you

1 Reply

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    So, just to understand exactly what you are trying to do, do you:

     

    1. Create a property (projectname) at Project level = the random number expression

    2. Make a request using a TestStep using the 'projectname' property

    3. validate the name using the 'propjectname'  property

     

    ?

     

    If its something like this,  then I would try creating and storing the 'projectname' property at TestCase level in the context holder - does this make sense?

     

    So, something like this:

     

    In a TestCase:
    1. Groovy TestStep: 

     

     

    context["projectname"]=TestProject#${=(int)(Math.random() * 90000 + 10000)}

    2.Make request using 'projectname' property

    3.Validate using the 'projectname' property

     

    I'm not sure if this is what you meant, but this way the projectname property should be the same for each run of the TestCase.

     

    Sorry if I got the wrong end of the stick!

     

    Cheers,

    Rupert