Forum Discussion

TCYKPB's avatar
TCYKPB
Contributor
3 years ago

Running tests by tag name in specific order

Hello, I will be running my suite of tests in a CI/CD pipeline (Jenkins) but I realized from the documentation that running tests by tag name (following the CLI commands) does not guarantee the tests will be run in a certain order. (Note: The tests that match the specified tag will be run in an arbitrary order.)

While trying to find a workaround to this inconvenience, I realized that it does indeed follow a specific order.

The order is given by how the test files are sorted in the file script.tcscript. So, for whoever needs to run their tests using tag names, and also wants to run a "pre-step test" or something like that, all you have to do is open that file on any text editor, and move the row where your test file is, up to the place first place, or at whichever place you want it to be executed.

Example:

 

# Assuming all tests have the tag "@Smoke"
<folder name="MaiGroup">
    <folder name="Group1">
        <child name="TestMethod1" key="ZZZZ-YYYYY-VVVVV}" path="File1.js" />
        <child name="TestMethod2" key="ZZZZ-YYYYY-VVVVV}" path="File2.js" />
        <child name="TestMethod3" key="ZZZZ-YYYYY-VVVVV}" path="File3.js" />
    </folder>
</folder>

# Test run for the @Smoke tag will look like:
TestMethod1
TestMethod2
TestMethod3
-----------------------------------------------------------
# Now, if we want to run TestMethod3 first, all we have to do is open the script.tcscript file and move the TestMethod3 to the first place:

<folder name="MaiGroup">
    <folder name="Group1">
        <child name="TestMethod3" key="ZZZZ-YYYYY-VVVVV}" path="File3.js" />
        <child name="TestMethod1" key="ZZZZ-YYYYY-VVVVV}" path="File1.js" />
        <child name="TestMethod2" key="ZZZZ-YYYYY-VVVVV}" path="File2.js" />
    </folder>
</folder>

# And now, the test run for the @Smoke tag will look like:
TestMethod3
TestMethod1
TestMethod2
 
-----------------------------------------------------------
 
Hope this helps someone, and maybe the TestComplete team can now update the documentation.
 
Regards.
  • smart_frog's avatar
    smart_frog
    New Contributor

    Hi there, thanks for your info, I find the file script.tcscript but the content doesn't look like test cases, thought the structures are the same as you present, is there a chance you happen to know what it is going on?