We’re happy to announce two of Runscope’s newest feature improvements for API testing — condition steps and cookie handling. The condition step is the newest test step type that makes tests more dynamic and flexible by coupling logic to actions. Cookie handling is a new feature for testing APIs that utilize client-side cookies (i.e. JWT with single page apps).
Condition Test Step
This new test step allows you to define an assertion and embed additional test steps that are executed only if the assertion is true. If the assertion evaluates false, those embedded steps are skipped, and the test continues to the next step. Note that a condition step assertion that evaluates to false does not make the overall test fail; however, any assertions embedded underneath the condition step that fail will make the overall test fail.
While there are many different testing scenarios that can benefit from the condition step, here are a couple of examples of how you might use it:
- Consolidate multiple environment tests into a single test to improve manageability. A common practice for testing different environments (e.g. local dev, staging, production) is to create individual Radar tests for each unique environment. Doing so can introduce more complexity in terms of test case management. With the condition test step, you can consolidate those into a single test, grouping the environment-specific test steps beneath a conditional assertion. Doing so also means having only one trigger URL across all environments.
- Create more robust and flexible tests that can react to dynamic payload responses. For performing tests in environments where API responses may vary from request to request, using condition test steps are particularly useful. Your tests can now be fluid with those response changes, helping to reduce failure false positives with binary test assertions. For example, imagine an API method called /billing/transaction/last that returns the last transaction made by a customer. The transaction type is either a payment or dispute. Using a condition test step you can create specific test steps for each transaction type, all within a single Runscope Radar test.
Some APIs use client-side cookies to store information about a resource or client state. For example, in a single page app, an API server may store an authentication token in a client-side cookie. Runscope test runs now have the ability to automatically handle cookies, just like a web browser.
Cookie handling is a behavior that can be turned on or off on a per test basis (off by default). When turned on, cookies will be automatically stored and sent which each request. Every test run begins with an empty cookie jar. To activate this feature for a test, navigate to the test's settings page and locate the Behaviors section.