You can use Reusable Snippets to create building blocks that cover common user flows so that test creation and maintenance are significantly quicker. Rather than repeatedly writing the same steps across 5, 10, or 100 tests for common actions like entering a username and password to log in your application, just write them once in a Reusable Snippet. Once you've created this Reusable Snippet you can use this building block to speed up test writing and maintenance. When flows change you can just edit your Reusable Snippet once and those changes propagate to any tests (or other Reusable Snippets) that contain that Snippet.
Reusable Snippets are similar to tests because they cover specific user flows and can be edited via the Visual Editor or Plain Text Editor, but they differ in a few key ways:
- Reusable Snippets can’t be run (Tests should cover end to end flows, Reusable Snippets are building blocks of tests)
- Reusable Snippets don't belong to Features, Saved Filters, Run Groups. They may span many Features and can't be run so these means of organization don't apply.
- Reusable Snippets don't have owners, priorities, or states (e.g. disabled vs active)
Any test steps that appear commonly within your user flows are great candidates for Reusable Snippets. We often see teams cover:
- Setting up a new account
- Adding items to your cart
- Checking out
You can create Reusable Snippets from existing test cases by extracting existing steps so don't worry if you haven't thought through your entire Snippet hierarchy from the start.
To extract these steps:
- Select the steps you wish to extract
- Select the pair of scissors > Extract Steps
- Confirm you intend to create a Reusable Snippet
You can also create Reusable Snippets from scratch:
- Navigate to the Test Page (or the Reusable Snippets, Features, or Run Group tabs)
- Select the Create button
- Select Reusable Snippet
- Use the Editor to add steps like you would for a test
Note that a Reusable Snippet’s starting URL is used to preload the platform for testing and can be redirected to in the middle of a test. When a Reusable Snippet is added to a test, the Snippet's starting URL is ignored by default, but select redirect if you'd like the tester to navigate to the Reusable Snippet's URL.
To add a Reusable Snippet to a Test or Reusable Snippet:
- Open or create a test
- Select the carrot icon next to Add a Step
- Select the Find an existing Reusable Snippet to embed option
- Either search or scroll to find the Reusable Snippet you plan to add (n.b. that only Plain Text Editor Snippets will appear here)
You can edit Reusable Snippets in one of two ways–
First, you can directly edit them via the Plain Text Editor by selecting them from the Reusable Snippets Tab just like you'd edit a test.
Or you can edit them directly in a parent test. To do this:
- Click the edit icon (pencil) next to the embedded Snippet. You'll just be able to edit the steps of that Snippet.
- Make your changes.
- Click the Save Changes button.
- Click the “Save” button to confirm you want to update all tests that include that Snippet.
- Continue editing the test.
Reusable Snippets appear under a tab on the All Tests Page. Here you can:
- Sort your Snippets Via the Column Headers
- Search through all your Snippets
- Use Bulk Actions to Delete or add Tags to Reusable Snippets
You can see where your Reusable Snippets are included in two places–
- In the Plain Text Editor you can see how many tests include that Snippet under settings at the lower right part of the screen.
- Under the Reusable Snippets Tab you'll see the Included Incolumn that summarizes how many Tests and other Reusable Snippets that Snippet is included in. Hovering over it shows you which specific Tests and Snippets those are.
Can Reusable Snippets be converted into Tests or vice versa?
No you can not directly covert a Reusable Snippet to a test. You can embed the Reusable Snippet in that test and then copy and paste steps directly into that new test.
To create a Snippet from a test, extract all the steps in the test to create a new Reusable Snippet.
Can I use a Reusable Snippet Created in the Visual Editor in a Plain Text Editor Test or vice versa?
No tests can only include Reusable Snippets created in their respective editors.
Updated 4 months ago