apiconnectapiconnect-test-monitor

How can I create an integration test using API Connect Test and Monitor?


I've been playing around with IBM API Connect Test and Monitor (looks like a free to use rival to Postman) and would like to create an integration test (a test with multiple steps).

Looking at the example APIs it seems like it's possible, e.g. /api/examples/retail/products returns a list of products and /api/examples/retail/product (singular) looks up information on each of the products. However I can't work out how to connect the calls together. Is this definitely possible and if so how do I construct the test?


Solution

  • It certainly is possible to create an integration test and I can try to talk you through the steps using the example API you mentioned.

    1. create a test in the normal way, go into "Compose" and then you may as well use the wizard option to choose "I got this, start from scratch"

    2. Add a request and choose GET, then specify https://us-east.apitest.apiconnect.ibmcloud.com/app/api/examples/retail/products as the URL. Set the variable field to something like "products_data" or whatever you like. Save that request by clicking the tick button.

    3. Add another request and choose "Each", set the expression to be the content of the variable you just defined, e.g. products_data.content.products. This will create a loop you can nest other requests inside. Again save and close with the tick button.

    4. Add another request, this time a "Set (variable)". The name can be just id or whatever you like. Set the mode to string, and the value to ${_1}. Click on the tick to close and then use the mouse to drag the variable piece so it's nested under the "for each" loop.

    5. Add one last GET request where the URL is the single item endpoint, e.g. https://us-east.apitest.apiconnect.ibmcloud.com/app/api/examples/retail/product. Inside Query Params, add the id query parameter and select "Variable" as the value, referencing id (the variable we just declared in step 4). Save and close the request and drag it into the for loop as well, underneath the variable.

    You should end up with something like this

    Now you can run the test and it should work, generating multiple calls to the single product endpoint.

    This will also work for login methods where you post to a sign-in page and obtain a session token, then use it for a set of other requests against secure endpoints.