Introducing Testfully Offline: Your Cloud-Free API Client Solution and a powerful Postman Scratch Pad alternative. Download
How does Testfully verify your API automatically?

How does Testfully verify your API automatically?



Introduction


Validation (sometimes called assertion or checks) is one of the core concepts of any testing tool. When it comes to validation of your API, Testfully verifies behaviour of each step within tests independently. Moreover, we support validation for the following aspects of APIs:

  • Response Code
  • Response Time
  • Response Body
  • Response Headers


1. Response Code


This optional validator is one you should probably set for all of the steps of a test case. Using it you can set what you expect as the “HTTP Response Code”. Testfully makes sure that the actual response code is exactly what you have defined as the expected one otherwise the test fails.

The example below shows a test case with a single “Response Code” validator. Here we expect to receive the “200 OK” code in response.

Set response code validation for your API test



2. Response Time


This optional validator is suitable for measuring the performance of your API and making sure that users get the response within the expected time frame. To configure this validator, simply provide the expected response time in milliseconds. Testfully compares the actual response time with the expected one and fails if the actual response time is greater than the expected one.

The example below shows how response time is configured for a test case to be 1200 milliseconds.

Set response time validation for your API test



3. Response Body


This optional validator is suitable to match the response against a provided JSON object. Testfully tries to match the provided fields in “Response Body” against the actual values in response and the test fails if at least one of the defined fields in “Response Body” section is missing or has a value that does not match the provided value.

The example below shows a valid JSON object in “Response Body” field. We’re expecting that:

  1. Response from API comes with a field called “success” and the field MSUT have “true” as value.
  2. Response from API comes with a field called “workspaceId” and the field value MUST be “928031722”.

Validate response body of a request

What would happen if API responds with the mentioned fields and some other fields, you might wondering? Well, Testfully simply ignores those fields and assumes those fields don’t exist at all.

A couple of things about “Response Body” you should probably know:

  1. The test fails as soon as one of the response body validations fail.
  2. Response Body only supports valid JSON data.
  3. Nesting is fully supported, you can even include arrays.


4. Response Headers


Response Headers validator is identical to Response Body, albeit it does the validation against the Response Headers.

The example below shows how we define “Content-Type” header field and corresponding “application/json” value as the expected header in response. This example contains only two headers but you can add as many as headers you want.

Validate response headers of a request

A couple of things about “Response Headers” you should probably know:

  1. The test fails as soon as one of the response header validations fail.
  2. Response Header only supports valid JSON data.
  3. Nesting is not supported.

Recent Articles

blog-image
Product Updates: August 2023

Welcome to the 3rd edition of What’s New in Testfully post! During August, we focused on the delivery of Testfully Offline, the ability to use Testfully without storing your data in the cloud. With a lot of progress on that front, we’re well on track to ship Testfully Offline in September. Also, we shipped two of the most requested features: HTTP Proxy and a new editing experience for JSON input fields.

blog-image
Introducing Testfully Offline: Your Cloud-Free API Client Solution

At Testfully, innovation is our driving force. We’re excited to unveil a groundbreaking addition to our lineup: Testfully Offline, an offline version of our esteemed Saas Product in the API Client sphere. This desktop application presents an identical experience to our cloud-based offering, with a significant twist that puts the power in your hands.

blog-image
Product Updates: July 2023

Welcome to the 2nd edition of the What’s New in Testfully blog post! In July, we marked the one-year anniversary of the transformative launch of Testfully’s API Client experience. To commemorate this milestone, we’ve diligently introduced 7 new features, made numerous enhancements, and conducted 10 releases. Let’s dive right in, shall we?