Create custom phrases that encompass a process, then use those phrases to make writing your tests even easier.
When to use phrases
Phrases allow you to condense multi-step processes into a single "Given" or "When" command that you can then use in as many tests as you like, saving you time and effort when creating tests.
For example, if a several of your tests begin with logging in somewhere, you can create a phrase that includes all of the commands it takes to log in, call that phrase something like "Given you're logged in," then type the phrase name "Given you're logged in" into your tests instead of writing out the included commands individually.
Creating a phrase
Clicking the "Phrases" link in the "Tools" menu (or going to the "Tools" landing page and clicking the "Phrases" icon) will take you to the "Phrases" page.
Click the "Create a New Phrase" button.
You will be taken to the "Create a Phrase" page, where you will give your phrase a name and a description and specify the exact commands that should be included in that phrase.
A few key points:
- Phrase names must begin with either "Given" or "When."
- The commands that make up a phrase should be written exactly as they would appear in a test. You can copy and paste commands from an existing test into the "Commands" text area if you like.
- Feel free to include commands for test data in your phrases.
Click the "Create" button, and you'll see your new phrase on the "Phrases" page.
You can access phrase actions by clicking the "Actions" menu for a phrase on the "Phrases" page.
To modify a phrase, choose the "Modify" option in the "Actions" menu or click the phrase's name. On the "Modify Phrase" page, you can change your phrase's name, description, and commands. You can also modify a phrase in the "Phrase Search" widget on the test editor page.
- To duplicate a phrase, choose the "Duplicate" option from the "Actions" menu. The duplicate phrase will have the same description and commands as the original, but the word "(Copy)" will be added to the end of the phrase's name so you can tell them apart.
- To delete a phrase, choose the "Delete" option from the "Actions" menu. Keep in mind that deleting a phrase may cause tests that use that phrase to behave unexpectedly.
Using phrases in tests
You can use your phrases in as many of your project's tests as you like. Simply type the phrase's name as if it were a regular command in our Library, or find the phrase in the "Phrase Search" widget and copy and paste its name into your test.
Compare this phrase-less test. . .
. . . with this test that uses a phrase:
When you're creating or modifying a test that includes a phrase, you'll notice an arrow to the left of that phrase in the center panel. Click the arrow to expand the phrase and view its included commands.
When you run a test that includes a phrase, Tellurium will see the phrase's name and perform all of the commands that are included in that phrase in order, just as if they weren't in a phrase at all.