Testing APIs with Mock apps
Modeling and testing APIs
Now that you can create and manage your API specs, let’s think about testing! TIBCO Cloud Integration includes an integrated testing capability that allows you to generate a mock application to see if your new API design matches your expectations. Once you create a mock app it will get a unique URL to share with, for example, front-end developers so they can start testing and designing end user applications before any code is ever written. That almost sounds too good to be true? Let’s spend a few minutes to create a mock app and see for yourself!
Create a Mock app
On the API specs page you can hover over your API, click on the context menu and select
Update your response
Remember the sample data we used to create the JSON schema? That sample data will be returned when you start testing your app. To view and update the sample data, click on your app to go the Apps detail page. By default the Implementation tab is selected, which is exactly the place we need to be. On that tab you’ll see all the resources your API spec has together with the methods (so in our case you’ll see a GET and POST for
After that click
Test your Mock
Now that everything is updates, let’s focus on testing! From the Apps page, click on
For the POST method, we also need an
You can click on Try it out! as well and you should see the response coming back
Okay, that is slightly underwelming… the responses are the same for both. That is totally expected as we copy/pasted the same sample for both the response of the GET and the POST method. Check the advanced topics to add a bit more logic to your mock app and make the answers a little different.
Check the logs
From the logs tab of the apps detail page you can view the logs. As logs are streamed from your app into TCI you can see them on the Log tab of your apps’ details page. Logs can be viewed in a scrolling real time display, or you can select a time range to view historical logs. So if you’ve been following along with this tutorial you should see both the GET as well as the POST methods being logged.