Forum Discussion

fazlook's avatar
fazlook
Frequent Contributor
9 years ago

Automate REST api using TC

Hi there,

 

I would like your input on automating a REST api application.

 

I have TC and mostly using JScript but I could use C# if needed.

 

Our webApi is set up on Windows server 2008 and I do have a URL to it. Currently I am testing this manually using POSTMAN and I would like to automate it.

How do I automate this one from a windows 8,10 machines where TC is installed ? What kind of project ? how do I start ? 

 

Any help would be appreciated, 

  • Hi,

     

    > When do I need the https://..... and when do I need the TestSuite ? can I develop all my stuff under the API testsuite ? why do I need the first one ?

     

    The first node (https://...) is where you create just a separate requests to play with their parameters and check that they work as expected. After you are done with some given request, you can include it into some test(s) from the second node (API Test Suite). Every test case can have not only one request, but include other requests, pass data from one request to another, execute some intermediate actions via script code (e.g. check or query database) and execute assertions to verify that the expected result was obtained.

    https://www.soapui.org/rest-testing/getting-started.html may provide you with better understanding of the said above.

     

    > where at the project variable ? under preference ? how do I call it though ? #variable# ?

    https://www.soapui.org/scripting---properties/working-with-properties.html, https://www.soapui.org/scripting---properties/property-expansion.html and related help articles should help with this.

     

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    There are two approaches.

    One is to use the existing SoapUI tool provided by SmartBear and use that to create your API tests and then integrate them into TestComplete.  Now, something that is not clear in the documentation is if you need the full paid version of SoapUI NG tool or if the free one will integrate as well... something for someone like HKosova to answer.  In any case, this provides a direct integration between a tool SPECIFICALLY designed for testing API and the TestComplete scripting engine.

    The other approach is one that I've used in the past where I programmatically created code using the MSXML2.HTTPXML and MSXML2.DOMDocument objects provided by Microsoft and build my own set of tests where I'd send requests and process the results I received back.  This, obviously, takes a little bit more work but if you can write the code, then I say go for it.

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    I'd say use the right tool for the job. In this case, SoapUI (free, open source) or SoapUI NG Pro (commercial, part of Ready! API). Both provide assertions, data-driven testing, built-in support for various authentication types (Basic, OAuth2, etc.), command-line interface aka testrunner, and much more.

     

    Ready! API also has a Postman plugin that lets you import Postman collections.

     

    You can run SoapUI and Ready! API tests from TestComplete. You can also run TestComplete tests from Ready! API (but not from the free SoapUI).


    tristaanogre wrote:

    Now, something that is not clear in the documentation is if you need the full paid version of SoapUI NG tool or if the free one will integrate as well...


    TestComplete can run both SoapUI (free) and SoapUI NG / Ready! API tests.

    • fazlook's avatar
      fazlook
      Frequent Contributor

      Thank you both. It will be my first time doing this. Can I just use an existing project ? or I need to create another type of projects ? Is there some examples somewhere about this ? Basically I need to post JSON and XML stuff. JSON is the main.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        I haven't had the pleasure of working with the SoapUI integration myself so I can't really help a lot there.

        However, to add the integration piece to your project (assuming you are licensed for web based testing), just right click on the project node in your project explorer, select Add -> New Item and then grab the Ready API/Soap UI item from the list.

        There are some tutorials and documentation available on line on how to go about doing the work.  I think HKosova has already linked to some of them.