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 else is help verify the business logic behind the API. It’s 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 log in, 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 that you may take in building a test. API Fortress is very capable of building a test draft for you. First, you must decide if you want to build a test manually. This can be done 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 a tutorial on the Visual Composer. The final screen of the tutorial provides you with more instructions on how to create a test. Close the tutorial 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:
Now, click the Generate Test icon at the top left 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.
At this stage, the test should be considered a draft. 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 Test Generation is great at understanding datatypes and structure, which is often 90% of the work. For an example of adding more intelligence to a test, please see the Appendix at the bottom.
Appendix: A Smarter Test
Furthermore, you may want to add more intelligence to a test to truly verify its accuracy. Let’s consider, for example, a scenario in which the following snippet of the payload is present only under certain conditions:
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 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, these assertions will only be evaluated 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 accomplished.