Handling Robot Framework Using Command Lines

Pradap Pandiyan
3 min readMay 15, 2023

--

Actually, the robot framework doesn't have any crazy IDE with all the relative support on it. The ride is an official IDE, which most people use for robot framework but in reality, it is like old school. The ride doesn't have integration with a lot of tools like Git, CI integration, etc.

Robot Framework

I personally use the command line for the robot framework in order to run the tests.

or a full list of command-line options sees robot --help or robot -h options.

Execute all test cases in folder(s)

To run all robot tests in the folder (including subfolders) use.

robot .

Execute all test cases in a single file

To run all robot tests in a single robot file:

robot example.robot      
robot path/to/<test_suite>.robot

Execute test cases by test name

To run test cases with specific test names:

use --test or -t option

Execute the test with a specific test name:

robot --test <test_case_name>.

Execute test cases by test name in a specific file:

robot --test <test_case_name> <test_suite>.robot

Also, partial test names and patterns can be used with --test option

Execute test cases by tags

Test cases and suites are annotated with tags (using [Tags] or Force Tags syntax) these can be executed by selecting tags to be included or excluded.

Example test suite:

*** Settings *** 
Force Tags suite
*** Test Cases ***
Test One [Tags] one No operation Test Two [Tags] two No operation

Also, partial tag names and patterns can be used with --include and --exclude option

Include test cases by tag

To run test cases with specific tag names included use --include or -i option:

robot --include <tag_name> .

Run a test with two tag names <tag_one> and <tag_two> in any file

robot --include <tag_one>AND<tag_two> .

Execute test cases with the tag “one” or “two” in one file:

robot --include <tag_one>AND<tag_two> <test_suite>.robot

Execute test case with <tag_one> and not <tag_two> in any file:

robot --include <tag_one>NOT<tag_two> .

Exclude test cases by tag

To run the test cases with specific tag names excluded use --exclude or -e option:

Execute test cases without <tag_two> in any file

robot --exclude two .

Execute test cases by suite name

In Robot Framework test folders and .robot files are considered test suites.

To run test cases in specific test suites use --suite or -s option:

Run a test with a particular test suite in any file

robot --suite <test_suite> .

Also, partial suite names and patterns can be used with --suite option

Execute failed tests

There is also a possibility to rerun all failed test cases and test suites.

Execute only failed test cases

To rerun failed test cases use --rerunfailed or -R option:

execute test cases failed in previous run (saved in output.xml)

robot --rerunfailed output.xml .

Execute failed test suites

To rerun test suites with failed test cases use --rerunfailedsuites or -S option:

execute test cases with failed test cases in previous run (saved in output.xml)

robot --rerunfailedsuites output.xml .

Using partial names and filter patterns

The presented --test, --suite, --include and --exclude options also support using partial names and filter patterns to match multiple names and tags:

Execute test cases containing name "test_case" in any file.

robot --test *test_case* .

Execute test cases "test_one" and "test_two" in any file.

robot --test "Example [test_one|test_two]" .

Execute test cases with tags starting with "test_one" in any file.

robot --include test_one* .

Execute test cases without tags ending with "test_two" in any file.

robot --exclude *test_two .

Execute test cases from suites starting with "test_suite" in any file.

robot --suite test_suite* .

Combining Filters

The presented --test, --suite, --include and --exclude options can be used also in combination:

Execute test cases containing the name “Example” and having tag “One” in any file.

robot --include One --test *Example* .

Execute test cases from suite “FeatureA” excluding tests with the tag “Smoke” in any file.

robot --suite FeatureA --exclude Smoke .

Execute test cases with the tag “Pending” from a specific file.

robot --exclude Pending example.robot

Conclusion

Robot frameworks have a great way of executing the test from the command line. It is easy and efficient to configure to run on the CI with a proper docker image.

Feel free to hit clap if you like the content. Happy Automation Testing :) Cheers. 👏

--

--

Pradap Pandiyan
Pradap Pandiyan

Written by Pradap Pandiyan

I’m a passionate QA Engineer. I’m a motovlogger, content creator, off-roader and freelancer. Buy me a coffee here https://www.buymeacoffee.com/pradappandiyan