In this lab, you will explore “Test APIs” feature of IBM API Connect that generates API tests automatically. By using IBM Api Connect TestAPIs capability you can deliver high quality APIs consistently and improve developer productivity with automation and AI powered testing capabilities.
Reference: https://www.ibm.com/products/api-connect/api-testing
You will be using Customer Database Rest API deployed in Lab1 to App Connect Dashboard.
From the Cloud Pak for Integration Platform Navigator, open App Connect Dashboard (student(n)-db).
Click on the Runtimes.
Select customerdatabase Integration Runtime, and click on the API, then “Download the OpenAPI Document” (yaml) as below.
Lets adjust the OpenAPI document to conform to the specification that API Connect Test APIs feature is expecting!
Edit the downloaded yaml file.
a) Append the below section above the schema: segement. Make sure it’s aligned propertly.
consumes:
- application/json
produces:
- application/json
b) Make sure the /customers/post: operation is defined before the “get” operation. if not move the “post” operation segment before the “get” segment as below.
From the Cloud Pak for Integration Platform Navigator, open API Connect Manager (apim-demo).
Click on the “Test APIs” tile.
Click “Add test suite”.
Test Suite name: student(n)-customerdatabase
Description: student(n) customer database test suite.
Click Save.
Click on the Test Suite tile that you just created.
xxxx
Click on “Tests” Option.
Click on <Add> to create a test.
Enter customerdatabasev1_test1 and hit continue.
Click <Template from Specifications> in the bottom middle option.
Select “Swagger 2.0 YAML”, and click on “drag a file here or click to upload”, select downloaded yaml file (as below).
Click Save.
Click on the dropdown, and select /customerdb/v1/customers/{customerId} operation.
Select “Smart Generator” circle as below, and click on the Tick mark on right of the window.
That should generate a POST, GET, and DELETE operations as below.
Now, add a variable “customerId” in between POST, and GET as below.
Click on the (i) circle on the GET opeartion, and select “add component before”.
Click on “Set variable” circle.
Set the variable name as customerId, and value as ${payload.id}.
Confirm changes by clicking the Tick mark on top right of the Variable window.
Modify the DELETE operation. Set Authorization default secret
Click Edit of Authorization header field, and enter value “secr3t” as below and click the Correct symbol to save.
Click <Save> button on the top, and then click <Run Test>.
Take the defaults, and hit <Run Test>, and that should generate a report as below.
Review and Close the Report.
Click on <Save and Exit> button on the top.
NOW CLICK <Publish> button as below.
Click on the Tests option on the top.
Click on the 3 dots on the test CustomerDatabasev1_test1 as below, and click Run. You can hit Run few times.
Click on the Dashboard on the top.
Here you can see the tests that were ran, and results with Graphs.