You can annotate your test scripts with tags to organize and run them by some criteria. For example, you can assign tags to all tests working with certain feature or running in certain environments, and then easily run all the tests for that feature or environment.
Set a tag
In the keyword test editor, if the Tags text box on the toolbar is not visible, click to show it.
In the Tags edit box, type the needed tag in the following format:
If you need multiple tags, separate them with spaces and start each tag with the
Save the changes.
A tag name should start with the
@character. Don’t put spaces between
@and the tag name, or anywhere in the tag name. Spaces are used as tag separators.
Don’t use parentheses in tag names. They have a special meaning.
Tag names are case-sensitive. That is,
@Reportsare different tags.
Run by tag
Option 1 – From the UI
In the Project Explorer panel, right-click the project node and then select a tag from the Run submenu (if the Project Explorer panel is hidden, select View > Project Explorer from the main menu to display it):
TestComplete will run all the tests – scripts, keyword tests, BDD scenarios and BDD features – that match the selected tag.
Option 2 – Run as a test item
Open the Execution Plan editor of your project. To do this, right-click the project node in the Project Explorer and then select Edit > Execution Plan from the context menu, or double-click the Execution Plan node in the Project Explorer.
In the Execution Plan editor, add a new test item to your project.
In the Execution entry column, click the ellipsis button and select the needed tag in the subsequent Select Test dialog:
TestComplete will add the “tag run” to the test item list. It will run all the tests that match the selected tag when you run the entire project or if you run the test item to which the “tag run” is linked:
When you run this test item or when you run the entire project, the test engine will execute all the tests that match the specified tag.
Option 3 – From the command line
To run tests that match a tag, use the
/test argument or the
/tags argument to specify the needed tag:
TestComplete.exe project-suite-file /project:project-name /test:"@tag1" /run
– or –
TestComplete.exe project-suite-file /project:project-name /tags:"@tag1" /run
To learn about TestComplete command line arguments, see TestComplete Command Line.
Run by tag expression
Option 1 – Run as a test item
Open the Execution Plan editor of your project. To do this, double-click the Execution Plan node in the Project Explorer or right-click the project node and select Edit > Execution Plan from the context menu.
In the Execution Plan editor, click New Test Item or New Child Test Item to add a new test item to your project.
Click the ellipsis button in the Execution entry column. In the subsequent dialog, select [Tag Expressions]:
Click the ellipsis button in the Parameters column. Specify the desired tag expression in the Value column of the subsequent dialog:
You can either enter the expression, or specify a project or project suite variable that stores the expression:
Notes on tag expression syntax
@before tag names, that is, use
To combine tags, use the
notoperations, for example:
@tag1 or @tag2
@tag1 and not @tag3
@tag1 and not @tag2 ← Correct!
@tag1 && !@tag1 ← Incorrect!
If needed, you can use braces to group tags, for example:
@tag1 and (@tag2 or @tag3)
(@tag1 or not @tag2) and (not @tag3 or @tag4)
Option 2 – Run from the command line
To run script tests and BDD features and scenarios that match a tag expression, use the
/tags command-line argument:
TestComplete.exe project-suite-file /project:project-name /tags:"@tag1 or (@tag2 and @tag3)" /run
To learn about TestComplete command-line arguments, see TestComplete Command Line.
Whenever you run tests by tags or tag expressions, the test order is not set, that is, the test engine runs the tests in an arbitrary order. If the order matters, you need to run tests in another way. For example, you can create test items, one for each test. Test items run in the explicit order – from top to bottom. See the description of the Execution Plan editor.
After running all the tests that match the specified tag or tag expression, TestComplete will collect their results in a single log and show the results grouped by the test names:
Stop tests on errors
If an error occurs during the test run, TestComplete will post an error message to the test log. Its further behavior depends on the following:
If the tests were run from the TestComplete UI or from the command line, the behavior will depend on the project’s Playback > On error property.
If the tests were run as a test item (specified in the project’s Execution Plan editor), the behavior will depend on the test item’s On error property (you set it in the Execution Plan editor).
Depending on the appropriate property value, TestComplete can do one of the following:
Continue the test run.
Stop the current test run and proceed with the next test matching the tag or tag expression.
Stop the entire test run.
For detailed information, see either the project’s Playback > On error property description or the test item’s property description, depending on the way you run your tests by tags.