python - Robot Framework - Syntax best practices -


i'm asking myself: "what robot framework's way choose between using python syntax or robot framework syntax in keywords?"

(and better in terms of performance/efficiency)

so if have documentations on subject (other "do/don't slides official site or advices, i'm more interested.

ps: sorry if it's not right place ask, don't know ask this.

below examples of typical cases when don't know robot framework "best practice".


examples:

1: (given ${string} string)

${char}=    evaluate    $string[-2] 

vs

@{chars}=    split string characters    ${string} ${char}=    list    ${chars}    -2 

2: (given &{arg})

${is_in}=    evaluate    'some_key' in $arg 

vs

${is_in}=    run keyword , return status    dictionary should contain key    ${arg}    some_key 

3: (given &{arg})

${value}=    evaluate    ('some_key' in $arg , $arg['some_key']) or "another value" 

vs

${is_in}=    run keyword , return status    dictionary should contain key    ${arg}    some_key ${value}=    set variable if    ${is_in}    &{arg}[one]    value 

4:

${arg['key']} 

vs

${arg.key} 

vs

&{arg}[key] 

one major concept of robot framework assist in abstracting technical python code away test suites/cases. provides many different libraries can use have been implemented in python , functionality can provided using robot framework keywords created.

in experience, lot easier , useful use robot framework syntax helps abstract technical code away, , if there functionality libraries cannot provide have flexibility create own libraries implemented in python.

the decision you're facing can different case case. in case better use keywords robotframework provided me.

robotframework.org provides user guide helped me understand , make decision before started creating test suites: user guide


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -