6/01/2017 Changelog Christopher Reichert

Triggers in Assertible are flexible way to run API or website tests at any time by calling a simple URL. While the Deployments API is specifically used for executing tests immediately after your application is deployed, triggers can be used to test your application during a continuous integration build, in a script, or from an external service.

We are happy to announce two major improvements to our Triggers API:

  1. Run your tests against any dynamic URL
  2. Fail your CI build when test runs fail

Try out Trigger URLs with a free account

Dynamic environment URLs for Triggers

Dynamic trigger environment URLs make it possible to run the same set of tests against any URL without needing to explicitly define an environment. These environments are known as transient environments and are common in several use-cases:

  • Continuous delivery pipelines where web app servers are created dynamically for reviewing and testing.
  • Testing an API on CI before deploying (using a localhost tunneling program like ngrok).
  • Testing URLs which are short-lived.
  • Programmatically initiating test runs and analyzing the results manually.

To execute tests against a dynamic URL using the Trigger API, use the url and environment parameters in the POST request body:

curl -XPOST https://assertible.com/apis/123e4567-e89b-12d3-a456-426655440000/run -d'{
  "environment": "my-dynamic-environment-xyz",
  "url": "xyz.staging.megacorp.com/api/"
}'

That's it!

**NOTE** If you are testing immediately after deploying your web service, the [**Deployments API**](/docs/guide/deployments) is the best bet because you can track versions of your application against test failures.

Fail your CI build when test runs fail

By default, Triggers submit tests to an asynchronous test run queue and return pending results immediately. This is inconvenient if you want to take action based on the results of the tests.

That's why we built a new parameter for the Triggers API named wait. Using the new wait parameter in the query string or request body will wait until the tests have completely finished executing. For example:

curl -XPOST https://assertible.com/apis/123e4567-e89b-12d3-a456-426655440000/run -d'{
  "environment": "staging",
  "wait": true
}'

The response will be a list of the final test results which can analyze to take some action like updating a status page or failing a CI build. For example, it's trivial to extract the final test result using jq:

RESULTS=$(curl -XPOST https://assertible.com/apis/123e4567-e89b-12d3-a456-426655440000/run -d'{
            "environment": "staging",
            "wait": true
          }')

echo $RESULTS | jq .[].result

Check out the Trigger docs for more info

If you have a feature request or questions, feel free to send us a message or reach out on Twitter any time.

:: Christopher Reichert

Categories

The easiest way to test and
monitor your web services

Define and test your web service with Assertible Track and test API deployments across environments Schedule API monitoring and failure alerts

Reduce bugs in web applications by using Assertible to create an automated QA pipeline that helps you catch failures & ship code faster.

Sign up for free