"

Simplify API Testing with API Fortress and qTest

By Jason Ioannides, API Fortress

Anyone that has tried to automate API testing with SoapUI/ReadyAPI, Postman or SOAtest will appreciate the simplicity of the API Fortress platform. Incorporating API Fortress with your Jenkins workflow allows the platform to test API endpoints every time there is a build. Through a simple integration, results will populate in qTest, alongside all your other testing results and metrics.

The API Fortress platform allows enterprises to quickly and easily create and execute powerful API tests. API Fortress integrates with many of today’s most powerful development and testing tools, including Jenkins and QASymphony’s qTest, a suite of tools that help enterprises streamline testing and simplify collaboration across projects, teams and methodologies.

In this blog post, we will demonstrate how you can create API tests using API Fortress, execute those tests as part of your continuous integration and delivery (CI/CD process) using Jenkins, and view the results report in qtest.

We’ll be talking more about API testing best practices and strategies during our session at QASymphony’s Quality Jam conference next week. Our session, “Testing Automation for the Entire API Lifecycle,” is scheduled for 2:50 p.m. on Tuesday, April 10. Blog readers can get $100 off Quality Jam tickets with the promo code Blog100.

Step 1 – Build an API Test

Creating a test with API Fortress is incredibly simple. Take a look at the video below to see how you can create a test in under a minute.

Step 2 – Install Jenkins Plugins (qTest)

Log in to your Jenkins account. In order for the qTest integration to work, we need to extend Jenkins with a couple of plugins. First, click “Manage Jenkins,” then click “Manage Plugins.”

We’re going to need both the qTest plugin,and the HTTP Request plugin. To find the plugins, click the “Available” tab in the Plugins menu and use the filter in the top right corner to search for them. Install both.

Step 3 – Integrate API Fortress into your CI/CD Process

The first step to integrating API Fortress into your CI/CD process is to grab the generated API hook for the project in question. To do so, head to the Settings panel in API Fortress. This view, seen below, can be accessed from anywhere in the application by clicking the Gear icon in the top right corner of the screen. Please note you need Manager access to generate a webhook. From Settings, click the API Hooks section and generate the hook for your project.

The next step depends on what you’re trying to test. The following steps are going to assume that you wish to run all of the tests in a project. You can also run a single test, or a series of tests with a certain tag. If you would like to learn more about that please contact API Fortress.

To import our data into qTest via Jenkins, we’ll export it in JUnit format using a query parameter. Since we already have our API hook, we just need to add the parameter to do so.

As it stands, our API hook is as follows:

https://mastiff.apifortress.com/app/api/rest/v3/86f81b19-2d29-4879-91d9-6dbb2271fec0861

The normal command to run all of the tests in the project, per the API Fortress docs is /tests/run-all, so we append this on to the end of the API call. We also need to request JUnit outputt via query parameters. First, we need to set sync to true, and then we can set format to JUnit. In short, we need to append ?sync=true&format=junit. That gives us the final API call:

https://mastiff.apifortress.com/app/api/rest/v3/86f81b19-2d29-4879-91d9-6dbb2271fec0861/tests/run-all?sync=true&format=junit

Great! If we make this API call via a browser or a tool like Postman, we can see our results in JUnit. We’re almost there.

Step 4 – Add API Fortress Step to qTest

From the Jenkins dashboard, let’s create a New Item. Next, we’re going to name and create a Freestyle Project. Click the OK button to proceed.

Scroll down the page until you see the “Add Build Step” pulldown menu. Select “HTTP Request.” This option will only be available if you installed the HTTP Request plugin in the previous step. We’re going to paste the API call we created above into the URL line.

Next, we’re going to click the “Advanced” button. Scroll to the bottom of the newly opened view and enter a filename of your choice into the “Output Response to File” line.

Now, we’ve enabled Jenkins to execute API Fortress tests and receive the test data in JUnit format. Next, we’re going to allow it to pass this data on to qTest.

Click on the “Add Post-Build Action” pulldown below the build step we just created and select “Submit JUnit Test Results to qTest.”

Now that we’ve told Jenkins to output the JUnit response to a file, we need to make that file accessible to downstream after-build steps. Click “Add post-build action” and select “Publish JUnit Results.”

In the new window, enter the same filename that we saved our JUnit data to in the API call in the previous step.

Enter the URL of your qTest instance and your qTest – Jenkins API Key. Click the “Retrieve Data” button to populate the next few menus. Select a project, release, and environment (optional) where you want to push the test results. Choose the final options with regards to how you wish the data to be stored in qTest, and click save.

From now on, every time you click “Build Now” with this test, the results will be exported to the qTest Project of your choice automatically. Simple, right?

API Fortress, Jenkins, and qTest are all individually powerful tools. When used together the strengths of each platform is magnified. API Fortress allows users to create powerful, readable tests in an extremely short period of time. Passing these results into qTest via Jenkins as a part of a CI/CD strategy allows these results to be viewed in the context of an entire testing suite. API Fortress was built with usability and integrations in mind, making it the perfect addition to your qTest and Jenkins process.

NEVER MISS AN UPDATE

Subscribe to Our Newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *

More Great Content

Get Started with QASymphony