Forum Discussion

Cata's avatar
Cata
Occasional Contributor
3 years ago
Solved

Can you modify a REST Resource path at a test step level?

Hi,

So I have the following resource path for a REST request: /api/task/7/initialize. The '7' is a dynamic value that is based on a number of tasks that are being created with a previous request. What I need is to take all of the previously created values and update them by using this request so I need to update this request every time with a new value instead of that '7' but I can't seem to be able to modify the resource path at a test case level, only at the API request level and that doesn't help me.

This seems like a really annoying limitation. 
Does anyone have any insight on this?


  • Hey Cata,

    Oh i think youre confusing the two issues. Just cos you have a parent/child relationship between api and teststep doesnt preclude you from updating a value in the teststep's URI during execution. This is standard stuff in ReadyAPI!/SoapUI.

    Firstly, you need to create the api with a parameter placeholder (either a RESOURCE/URI/TEMPLATE parm or a QUERY/MATRIX parm)

    You stated that the previous teststeps in your test generate the value you want to pass onto the relevant parameterised teststep right?

    Then thats exactly what you do when the testcase.executes. there arw multiple ways for a request to source a dynamically generated value. Im typing this out on my phone, but ir no one provides detailed instructions by time im in front of laptop, i will.

    Cheers

    Rich

4 Replies

  • richie's avatar
    richie
    Community Hero

    Hey Cata 

     

    You need to edit the parameter at API (on either RESOURCE or METHOD level) because your test step can be considered a child of the parent API (i.e. there is a relationship between them).

     

    One of the advantages to this approach is that what you change in the API, the change is reflected in the associated test step (for the most part) and if your project has thousands of teststeps associated with your API, this approach saves you having to edit every single teststep!

     

    The limitation to this is that if you want most of your teststeps associated with the API to have a certain QUERY parameter, but some teststeps associated with the same API to say for example set the parm as PLAIN - this won't work - you'd need to create a separate API in your project for this.  

     

    There are I'm guessing other limitations but the advantages of this child/parent relationship far outweighs the disadvantages I think.  This is my personal opinion however and isn't necessarily true!

     

    Cheers,

     

    Rich

    • Cata's avatar
      Cata
      Occasional Contributor

      Hi richie. Thanks for the reply.

      Now, I understand the design but this still doesn't change the fact that it is still  a problem if you can't modify the resource path at a test step level.
      I'm sure there are others who have run into such an issue.
      I NEED to be able to have the request's resource path updated during the test run process because that value is always going to be based on the response of a previous request and it's never going to be the same so I can't set it at the API level.

      • richie's avatar
        richie
        Community Hero
        Hey Cata,

        Oh i think youre confusing the two issues. Just cos you have a parent/child relationship between api and teststep doesnt preclude you from updating a value in the teststep's URI during execution. This is standard stuff in ReadyAPI!/SoapUI.

        Firstly, you need to create the api with a parameter placeholder (either a RESOURCE/URI/TEMPLATE parm or a QUERY/MATRIX parm)

        You stated that the previous teststeps in your test generate the value you want to pass onto the relevant parameterised teststep right?

        Then thats exactly what you do when the testcase.executes. there arw multiple ways for a request to source a dynamically generated value. Im typing this out on my phone, but ir no one provides detailed instructions by time im in front of laptop, i will.

        Cheers

        Rich