1
votes

I have a function in python I want to call and check if it is true or false. This would work fine coming back to robot and using 'should be true' the only problem is the function needs to take parameters.

Ex.

should be true | Check Value | nTimes | nSeconds | expectedValue

'Should be true' only takes 1-2 arguments and I am giving it a keyword and 3 arguments. Is there syntax like parentheses to overcome this or do I need to use something other than 'should be true' from the robot library?

My solution now has been to return the function to a variable and then test the variable with 'should be true' but I really want this to be simpler than that and condensed to one line.

1

1 Answers

1
votes

Should be true compares two values. You cannot use Should be True to run another keyword.

What you are doing is the correct approach: call your keyword, save the value, and then give the value to Should be true:

${result}=  Check Value 10  20  42
Should be true  ${result}

Another option is to have Check Value do the assertion itself. After it does what it does now it can throw an exception if the result isn't True. The exception will be reported by robot as a keyword failure.

For example:

# your library
def check_value(nTimes, nSeconds, expectedValue):
    <all of your existing code>
    if not result:
        raise Exception("check value returned a false value")

# your robot test
*** Test Cases ***
Example
    check value  10  20  42