Nemelis
Nemelis

Reputation: 5480

Can Robot Framework test suites be called with command-line parameters?

We are developing / publishing robot-tests in a git environment, where the public (published) git has slightly different settings then the development git (due to personal work-space (development) vs global environment settings).

Because of this one of our robot keywords is different for development and public. Currently we manage this by commenting out 1 line in the keyword's .robot implementation for the development git and another one for the public git, but this is error prone.

Is it possible to call pybot with some extra command-line options which will be passed on via the .robot files to the python files implementing the final keywords so we can move the 2 lines from the .robot file to the python implementation and decide which to use based on the given command-line option?

Upvotes: 2

Views: 951

Answers (1)

Bence Kaulics
Bence Kaulics

Reputation: 7281

Check the Setting variables in command line part of the user guide. With the --variable MYVAR:value command line argument you can create global variables.

For example:

*** Variables ***
${VAR}    localenv    # this is not necessarily needed, it is used to set default value

*** Test Case ***
Test
    IF    '${VAR}' == 'localenv'
        Log    Do this
    ELSE IF    '${VAR}' == 'globalenv'
        Log    Do that
    END

Run locally

robot test.robot

on global:

robot --variable VAR:globalenv test.robot

Upvotes: 4

Related Questions