Yesterday a colleague learning test automation forgot the syntax for running Robot Framework test cases from command-line. Although full command-line syntax is described on the Robot Framework User Guide it is rather long and tedious document to dive into.
This post aims to provide quick introduction for executing single, set or all Robot Framework test cases in a project.
Basic syntax
The basic syntax for executing Robot Framework tests from command line is:
For full list of command-line options see robot --help
or robot -h
option.
Execute all test cases in folder(s)
To run all robot tests in the folder (including subfolders) use .
Execute all test cases in single file
To run all robot tests in single robot file:
Execute test cases by test name
To run test cases with specific test name use --test
or -t
option:
Also partial test names and patterns can be used with --test
option, see Using partial names and filter patterns.
Execute test cases by tags
Test cases and suites annotated with tags (using [Tags]
or Force Tags
syntax) can be executed by selecting tags to be included or excluded.
Example test suite:
Also partial tag names and patterns can be used with --include
and --exclude
option, see Using partial names and filter patterns.
Include test cases by tag
To run test cases with specific tag name included use --include
or -i
option:
Exclude test cases by tag
To run test cases with specific tag name excluded use --exclude
or -e
option:
Execute test cases by suite name
In Robot Framework test folders and .robot
files are considered as test suites.
Example suite structure:
To run test cases in specific test suiteuse --suite
or -s
option:
Also partial suite names and patterns can be used with --suite
option, see Using partial names and filter patterns.
Execute failed tests
There is also 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 failed test suites
To rerun test suites with failed test cases use --rerunfailedsuites
or -S
option:
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:
For full list of supported filter patterns see User Guide section Simple Patterns
Combining filters
The presented --test
, --suite
, --include
and --exclude
options can be used also in combination: