How to execute tests in sequential order in robot framework?

Hi,

Is there a way to execute tests present inside a test suite in a certain order?
while using gird, for certain tests we don’t want the tests to be picked up by different machines and get executed in parallel.
Any way we can mark a suite/tests to run in sequential order instead of executing in parallel.

Thanks!

You can rename files, folders and test names to be prefixed with numbers and _.

For example:
Test Number One01_Test Number One
Test Suite One01_Test Suite One
Test Suite One/Test Number Two.robot01_Test Suite One/02_Test Number Two.robot

This is a feature since the beginning of Robot Framework, and if you use RIDE, the numbers are omitted from the view of test suites.

1 Like

Thanks @HelioGuilherme66
will try this.

1 Like

Hi,

I have at least ten test suites each having at least 10 test cases. I would like to know if there is a way to run selected tests from each of the suites in an order I would like.

For example, with the following test folder structure:

|--------Tests
|—Suite 1
|-------Test 1
|-------Test 2
|-------Test 3
|—Suite 2
|-------Test 1
|-------Test 2
|-------Test 3
|—Suite 3
|-------Test 1
|-------Test 2
|-------Test 3
Now I want to run the tests in the order for example as below,

1. Suite 1 - Test Case 3
2. Suite 2 - Test Case 2
3. Suite 1 - Test Case 2
4. Suite 3 - Test Case 3

Please note that the tests are not in any random order, it fulfills specific requirement for us. Likewise, there are multiple sequences that testcases has to be executed therefore I cannot rename suites or testcases.

Thanks!

You can prepare the arguments to Robot Framework, based on the documentation:

-t --test name *         Select tests by name or by long name containing also
                          parent suite name like `Parent.Test`. Name is case
                          and space insensitive and it can also be a simple
                          pattern where `*` matches anything, `?` matches any
                          single character, and `[chars]` matches one character
                          in brackets.
    --task name *         Alias to --test. Especially applicable with --rpa.
 -s --suite name *        Select suites by name. When this option is used with
                          --test, --include or --exclude, only tests in
                          matching suites and also matching other filtering
                          criteria are selected. Name can be a simple pattern
                          similarly as with --test and it can contain parent
                          name separated with a dot. For example, `-s X.Y`
                          selects suite `Y` only if its parent is `X`.

So for your example, it would be:

robot -t Suite_1.Test_Case_3 -t Suite_2.Test_Case_2 -t Suite_1.Test_Case_2 -t Suite_3.Test_Case_3 ./Tests

You can also have those arguments in an Argument file, for example arguments.txt:

-t Suite_1.Test_Case_3
-t Suite_2.Test_Case_2
-t Suite_1.Test_Case_2
-t Suite_3.Test_Case_3

And then use:

robot -A arguments.txt ./Tests

This is the option:

 -A --argumentfile path *  Text file to read more arguments from. Use special
                          path `STDIN` to read contents from the standard input
                          stream. File can have both options and input files
                          or directories, one per line. Contents do not need to
                          be escaped but spaces in the beginning and end of
                          lines are removed. Empty lines and lines starting
                          with a hash character (#) are ignored.
                          Example file:
                          |  --include regression
                          |  --name Regression Tests
                          |  # This is a comment line
                          |  tests.robot
                          |  path/to/test/directory/
                          Examples:
                          --argumentfile argfile.txt --argumentfile STDIN