Avoiding return values to test level?

Passing and returning values

  • Common approach is to return values from keywords, assign them to variables and then pass them as arguments to other keywords.
    • Clear and easy to follow approach.
    • Allows creating independent keywords and facilitates re-use.
    • Looks like programming and thus not so good on the test case level.
  • Alternative approach is storing information in a library or using the BuiltIn [Set Test Variable](http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Test%20Variable) keyword.
    • Avoid programming style on the test case level.
    • Can be more complex to follow and make reusing keywords harder.

In short, set test scope variables instead of returning values in keywords called from the test level. This is, of course, bad practice from a programming perspective.

${thingId} Create Thing
Go To Home Page
Open Thing ${thingId}


Create Thing
Go To Home Page
Open Thing ${THING_ID}

If I call Create Thing twice, the test variable now needs to be a list. If one is, say, with a customer and the other without, I can’t name them ${withCustomer} and ${withoutCustomer} since all I have is ${THINGS}[0] and [1].
If I have a keyword used in 864 places and call it from the test level for the first time, I have to write a separate keyword to call it and store the return value in a test variable.
Same if I call something from an outside library; write extra wrappers.

Essentially I can’t name variables based on what they mean in the context and the implementation/functionality of a keyword differs based on where future generations will call it from.

Do people actually follow this no-return-values-on-test-level rule? I see zero benefit and lots of problems.