Forum Discussion

AsadGilani's avatar
AsadGilani
Occasional Contributor
4 years ago

ReadyAPI Functional Testing Automate Problem

I am writing the test suite for my endpoints.I am having one problem which is for running the 1 test suite twice. For Example, When I add an image with endpoints it adds the Image with a unique Id and returns successfully. This unique Id is generated new every time. So we have another endpoint where we pass unique IDs to delete. So it is successful for the first time but when we run the delete second time the same query then that id is deleted and it says it does not exists. how do we automate this thing? I mean the test case should not fail.

I tried to search but could not able to find any resource, Any help will be appreciated. Thanks.

13 Replies

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 2

    Hi,

    I saw this post on Stack Overflow, and I've read it here.  I'm still not sure what the flow of your tests is.

     

    Here's how I understand it...

    • You POST an image and get a unique id indicating the id of the image
    • You call DELETE, use the id from Step One and image is deleted
    • You call DELETE a second using the id from Step One and the response is 'id does not exist'.

    I'd say above behaviour is right and the issue you're seeing is more to do with the way you're organising your test(s).  I think I can help, but I have to understand your test flow and and how you're organising your tests.

     

    The bit I struggle with is the 'second' run.  Do you the whole Test Suite twice?  Or just call DELETE twice?

    E.g.

    Whole Suite twice:-

    First Pass

    • You POST an image and get a unique id indicating the id of the image
    • You call DELETE, use the id from Step One and image is deleted

    Second Pass

    • You POST an image and get a unique id indicating the id of the image
    • You call DELETE, use the id from Step One and image is deleted

     

    Delete Called Twice

    • You POST an image and get a unique id indicating the id of the image
    • You call DELETE, use the id from Step One and image is deleted
    • You call DELETE a second using the id from Step One and the response is 'id does not exist'.

    Can you provide some screenshots of how your tests are organised and clarify what you're doing a little further?  There's a lot of really, really good and skilled people on this site and i'm sure once the flow is clearer, you'll get a solution.

     

    • richie's avatar
      richie
      Community Hero
      ChrisAdams

      I was just about to ask the same questions!

      Nice layout/explanation on your points fella,

      Rich
    • AsadGilani's avatar
      AsadGilani
      Occasional Contributor

      ChrisAdams: Thanks for your reply. I tried with your solutions and it seems that approach is correct but I got some swagger compliance assertion error.
      Let me write my workflow
      step1: I called my POST method with some data to upload that return successfully with no error.
      Step2: I tried to GET that data based on the unique Id which is generated by the POST method as suggested by you I used the value POST response Id in GET method.
      Error in the step: Swagger Compliance Assertion -> No resource that matches the OpenAPI definition.

      Step3: I tried to Delete that data based on the unique Id which is generated by the POST method as suggested by you I used the value POST response Id in DELETE method.
      Error : Valid HTTP Status codes - > Response status code 405.
      Error :Swagger  Compliance Assertion-> No resource that matches the OpenAPI definition.
      For me its totally strange because if I am passing the unique id directly then it deletes successfully.
      I am using the latest version of ReadyAPI 3.5.1



      • ChrisAdams's avatar
        ChrisAdams
        Champion Level 2

        Hi,

         

        How are you passing the id?  Are you using Property Transfer to 'pull' the id into the delete step?  I see you got some good feedback on Stack Overflow.

        It's difficult to see why you are getting a 405 when trying to 'automate' versus testing the hard-coded value with some screenshots.

        The only thing I can suggest here is that once you run the test using the method that returns the 405, have a look at the 'raw' tab on the request.  The 'raw' tab shows exactly what SoapUI sends to your API.  Compare what you see in 'raw' using the working a failing approaches.  Hopefully that will show some difference to help you resolve your issue.