This is a quick "how to run" if you already have everything Robot Framework-related installed. This Gist might be especially handy for those you either just starting out, or if you've inherited a code-base from someone else.
The following assumes you have a terminal (CMD or PowerShell on Windows, Terminal on Mac or Linux) and aren't afraid to use it.
cd
into the root directory of the Robot Framework files and test cases; we'll assume all test cases are somewhere within a directory namedtest_cases
.- If the directory doesn't already exist, then
mkdir reports
(this is a convenience - where our reports will live). - Execution step:
robot -T -d reports -n noncritical test_cases
- You'll see a bunch of stuff on the terminal. Get some ☕ if you have many tests.
- When it's done, you'll see the report (timestamped) in the
reports
directory; double-click thereport-
YYYYMMDD-
HHMMSS.html
(where YYYYMMDD is the year, month, date and HHMMSS is the hour, minute, and seconds - e.g,report-20170302-114737.html
).
-T
- Short for--timestampoutputs
. Creates reports, logs, etc. with the current timestamp so we don't overwrite existing ones upon execution.-d
- Short for--outputdir
. Tells the framework where to create the report files.-n
- Short for--noncritical
. This tells Robot Framework what tag indicates a non-critical test (I've standardized onnoncritical
to reduce ambiguity).
There's one more switch you should probably use: --dryrun
. This tells Robot Framework to run through all of your test cases, resource files, etc. looking for syntax-type problems. Recommended as it can save some headaches if you have a lot to execute. You can add it anywhere in the command line.
To execute only the test cases with a particular tag, do everything in Testing ALL THE THINGS above, except in step 3, perform:
robot -T -d reports -n noncritical -i NAMEOFTAGHERE test_cases
Substitute NAMEOFTAGHERE
with whatever is appropriate; e.g., smoke
or api
. This will execute all test cases that include the tag you specify. The -i
is short for --include
which means "include for testing only those test cases with this tag".
Also, you can "stack" the selected tags by repeating the switch and tag name. For example, you could do -i negative -i smoke
and it would execute all test cases which have a tag of both negative and smoke.
To execute only a particular test suite (file), do everything in Testing ALL THE THINGS above, except in step 3, perform:
robot -T -d reports -n noncritical test_case/path/to/case.robot
where /path/to/case.robot
is of course the path to the suite (file) you want to execute.
To execute only a particular test case, do everything in Testing ALL THE THINGS above, except in step 3, perform:
robot -T -d reports -n noncritical -t "Name of Test Case Here" test_case/path/to/case.robot
where "Name of Test Case Here"
is the name of the test case within the file pointed to via /path/to/case.robot
. For example, if you wanted to execute the test case Verify All Widgets Present within the Smoke - Dashboard Page suite, you'd execute:
robot -T -d reports -n noncritical -t "Verify All Widgets Present" test_case/path/to/dashboard_tests.robot
See the official word on all command-line switches. Have fun!
How to run all test in one directory?
sample/test_01.robot
sample/test_01_resource.robot # resource file of test 01
sample/test_02.robot