Is there any way to send arguments/values to Robot test cases from jenkins?

Sthuthi Bhat picture Sthuthi Bhat · Jun 3, 2015 · Viewed 9.2k times · Source

I have automated test which takes input from the user and runs the test. Any idea on if we can give the argument from jenkins for the robot testcase and run the test?

ex: scenario: Test if a lighting device works well or not. steps:

  1. ssh login to light device,
  2. run some predefined set of commands,
  3. verify the lighting_flag set to 0 or 1,
  4. ssh logout from device

In this case, I need to take light device username and password as input from user. Is it possible to get it from jenkins (build with parameters) and run the robot test case?

Answer

janne picture janne · Jun 3, 2015

You can use variables. For example, a user keyword connecting and logging in might be like:

Connect To Device   
    [Arguments]    ${HOST}
    Open Connection     ${HOST}
    Login    ${USERNAME}    ${PASSWORD}

Now, provided your Jenkins parameters are username and password, you can use the execute shell task like this:

 pybot --variable USERNAME:[username] --variable PASSWORD:[password] <path/to/tests>

This sets global variables ${USERNAME} and ${PASSWORD} for the test execution.

More info in the user guide.