API Fortress is focused on API Quality. That means performance, uptime and accuracy. That last part is where we really differentiate ourselves. The metrics of an API call are important, but what we do better than anyone is help verify the logic of the API. It is more than schema validation, and requires zero coding.
Below we will show you how to quickly create a test using an e-commerce API.
Let’s get started!
Step 1: Create a Project
When you first login, you are introduced to the Company Dashboard. The company already contains a project called Examples with some example tests. Click Create Project.
Step 2: Create a Test
Step 3: Choose Your Test Creation Method
Once you have named your test you will be redirected to the Interstitial page. There are two avenues to take in building a test. API Fortress is really good at building a test draft for you. First you must decide if you want to build a test manually, from a Spec File, an Apiary account, or using the tool we call Magic. Since this is a quick start guide, we will show you how to use Magic. To build using a Spec file see http://apifortress.com/doc/build-from-spec/, or from an Apiary account see http://apifortress.com/doc/build-from-apiary/.
Step 4: Create a Test Using Magic
Click on Compose.
Next, you will be presented with an introduction to the Visual Composer. The final screen of the introduction provides you with more instructions on how to create a test. Close the introduction and open the Console by clicking on HTTP Client button in the left panel.
For this example we will use our own test API. It’s a simple GET, so you can leave the dropdown as it is and enter the following url:
Once done, click the Send button and the response payload will appear.
Now, click the Magic Wand icon at the top right corner of the Console to launch the Magic tool.
The following screens will allow you to choose whether you want to create the input set based on the data provided in the request, and if you want Magic to generate the assertions. The final screen summarizes what was done. Press Continue on each screen.
We call it a draft because you should take a moment to verify each object, and/or add more logic to it. API Fortress has a lot of tools that allow for comprehensive continuous integration testing. Magic is great at understanding datatypes and structure, which is often 90% of the work. For an example of adding more intelligence to a test see the Appendix at the bottom.
Appendix: A Smarter Test
Furthermore, you could want to add more intelligence to the test to truly verify its accuracy. Let’s consider, for example, a scenario where the following snippet of the payload is present only certain times:
while the payload often contains this snippet:
Since the “modes” and “zones” are present only when “available” is true, we could add an IF condition that differentiates the two different scenarios.
Select the assertion (as shown above), then click on the three green dots on the left of that assertion. Choose ‘add component after,’ select the ‘IF’ component, and then type in the “field” this code: payload.content.shipping.available==true
Then, drag and drop the following two assertions (“modes” and “zones”) inside the IF component. Now, those assertions will only be executed when “available” is true.
That is one of many examples of the flexibility and power of API Fortress. Nest GET statements together, use the WHILE or EACH component. Almost anything you can think of can be done.