Forum Discussion

Premier2k's avatar
Premier2k
Occasional Contributor
9 years ago

Setting a URL in test

Hi all,

 

Looking for some advice here.

 

We have some URLs that call a particular a stub i.e. /company.api.host/api/applications/stub/applicants and then I have some params which follow that, i.e. ?fields=something

 

I want the ability to set the stub I want to use in my test case, is this possible? I've considered using a property transfer to do this but it doesn't appear I can do it with that. I can only set a project property.

I've looked at templates but unless I'm misunderstanding them, I have to set them before I run my tests. I would rather set in my test case at runtime.

 

So basically, I want to be able to have a test step that replaces stub with MDIP1 or MDIP2 etc etc...

I hope that makes sense...

 

--Premier2k

3 Replies

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    The property transfer is definately the option I use, although I sometimes find it easier to use an HTTP Request TestStep instead of a REST TestStep, as the HTTP one allows you to replace the entire URL string - see :

     

    http://community.smartbear.com/t5/SoapUI-Open-Source/Parametrizing-Endpoint-Resource-Method-and-paramter-values-in/m-p/102919#M18026

     

    This post goes beyond your needs, but discusses / links to information regarding how to set HTTP TestStep endpoints (beware there is an issue with the editor forcing the URL to lower case, reported as a bug).

     

    Hope this helps,

    Cheers,

    Rupert

  • Premier2k's avatar
    Premier2k
    Occasional Contributor

    Thanks Rupert,

     

    I managed to get this working using the project properties. When I first tried this I made a mistake in my URL and didn't realise. I had put ${Project#stub} of course omitting the first #. Now I've corrected that it works fine.

     

    Is your book available on amazon? Where can I purchase this?

     

    Many thanks for your reply,

     

    --Premier2k

    • rupert_anderson's avatar
      rupert_anderson
      Valued Contributor

      No problem, the syntax is easy to forget, as it has exceptions like when referencing a property from the context variable you don't actually need the # e.g. ${contextProperty}. Well done sorting it out.

       

      Thats very kind of you to ask, it is available on Amazon, but I must admit that the cheapest place to get it is from the Packt site https://www.packtpub.com/web-development/soapui-cookbook, as they have a promotion on at the moment across all e-books - hope you like it! :-)

       

      Happy scripting! 

       

      Cheers,

      Rupert