Get information about usage of "--exitonfailure" command line option at test suite run-time

130 views
Skip to first unread message

32BIGFREE

unread,
Oct 4, 2016, 7:09:41 AM10/4/16
to robotframework-users
Hello,

when a test suite is executed (e.g. via pybot) the "--exitonfailure" command line option can be specified.
In our project we need to distinguish whether this option has been specified or not (it can be specified directly on command line or in the argument file).

Is there any way how to get information about "--exitonfailure" in the test suite run-time?

Note: We have studied the source code of robotframework and it seems that the command line options nor setting are accessible in the run-time later on.
Instance of Runner contains settings but we do not know how to access it from test suite (if it is possible at all).

Thank you.

Best Regards
Michal Svoboda

Pekka Klärck

unread,
Oct 4, 2016, 7:27:31 AM10/4/16
to 32bi...@gmail.com, robotframework-users
2016-10-04 12:22 GMT+03:00 32BIGFREE <32bi...@gmail.com>:
>
> Is there any way how to get information about "--exitonfailure" in the test
> suite run-time?

Not directly. You could get this information via Robot's internal
APIs, but that's a risky approach because these APIs can change.
Alternatively you could look at Python's `sys.argv` directly, but
that's also a bit risky/complicated because Robot supports long
options in case-insensitive manner (e.g. `--ExitOnFailure`), allows
shortening options as long as they are unique (e.g. `--ExitOnFail`)
and RF 3.0.1 will add `-X` shortcut for this particular option.

Exposing command line options somehow would be a nice general
enhancement. Someone should just design a good APi and provide a pull
request. I doubt I have time for that in the foreseeable future, but I
can help if someone else is interested.

Currently the easiest way to signal something like this to tests is
setting a variable that tells is the option enabled or not. You could,
for example, run tests like `--exitonfailure --variable
EXIT_ON_FAILURE:True`.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org
Reply all
Reply to author
Forward
0 new messages