At Assertible, we want to promote best practices, reliability, and
simplicity in our API testing platform. It's important that tests are
reproducible while being flexibile enough to model real-world use
cases and validate a series of HTTP requests.

This is why we're exicted to
release teardown steps, the
counterpart of setup steps. A
teardown step is an HTTP request that runs after the test, and can
be for things like testing logging out of a web app or removing
test data left over from the test.

Using teardown steps to clean up data from the test

Teardown step example

For a basic example, let's demonstrate testing a CRUD operation for
a REST API. Pretend you have an API with a /users endpoint, and
you want to create a test to validate POSTing a new user, ensure it
was saved correctly, and delete the user after the test.

In Assertible, this would be a 3 part test:

Setup step

Create a setup step that POSTs a new user. In the setup
step, you can save the id returned from the API after posting a
new user in a {{userId}} test variable.

Test

The test itself will make a GET request to /users/{{userId}}
using the {{userId}} variable saved in the setup step. If the
setup step failed to save the variable, or it's not available, the
test will fail.

Teardown step

Set up teardown step that makes a DELETE request to
/users/{{userId}} using the same{{userId}} variable saved
in the setup step.

This structure allows you to have a fully encapsulated,
reproducible, and side-effect free API test. This test doesn't rely
on previous tests setting variables correctly, and it doesn't rely on
a complex series of requests as a pre-requisite.

When it comes to automating API tests, this structure is ideal
becauase it lowers the probability of a flaky test, isolates test
dependencies, and can easily be automated. This is a simple example,
but displays the power of a structured API test framework and
provides a good starting point to test more complex API workflows.

Continuing development

We have big plans for improving and extending setup and teardown steps
as we continue to build and develop new tools for web service
testing. Supporting capturing variables in teardown steps, and
having multiple setup steps are on the roadmap, so stay tuned.