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.
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,
@Reports are different tags.
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.
Open the Test Items page of your project. To do this, right-click the project node in the Project Explorer and then select Edit > Test Items from the context menu, or double-click the project in the Project Explorer and then switch to the Test Items tab.
On the Test Items page, 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.
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.
Open the Test Items page of your project editor. To do this, double-click your project in the Project Explorer and then go to the Test Items tab, or right-click the project node and select Edit > Test Items from the context menu.
On the Test Items page, 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:
@ before tag names, that is, use
@tag1 rather than
To combine tags, use the
not operations, for example:
@tag1 or @tag2
@tag1 and not @tag3
not rather than
@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)
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 Test Items page.
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: