MarketSquare / robotframework-tidy

Robot Framework code formatter
https://robotidy.readthedocs.io/
Apache License 2.0
107 stars 16 forks source link

Missing new keyword 'setup' setting in OrderSettings transformer #690

Closed gohierf closed 6 months ago

gohierf commented 6 months ago

Since RF 7.0, keywords now accept a setup argument.

This is not yet supported by robotidy OrderSettings transformer and result in the following error:

Error: OrderSettings: Invalid 'keyword_before' parameter value: 'arguments,documentation,tags,timeout,setup'. Custom order should be provided in comma separated list with valid setting names: arguments,documentation,return,tags,teardown,timeout

Side note, regarding documentation

While we are on the subject of OrderSettings transformers, I found that the documentation is lacking the following:

Another side note, regarding robotcode

My need to put the arguments setting first originated from a current limitation in robotcode. Maybe you have some information to share on the topic?

bhirsz commented 6 months ago

1) Thanks for pointing it out, it will be fixed

2) And thanks for all notes for documentation - it's really helpfull as the tool is only as good as its documentation, with missing bits it would be not used :)

3) Looking into it, I believe the timeout default order should be moved. Ideally after arguments since it can have variables from arguments (which btw may not be supported by robotidy/robocop variable rules/transformers)

bhirsz commented 6 months ago

Style guide already propose (based on User Guide) a bit better order:

https://docs.robotframework.org/docs/style_guide#settings

I've also checked - [Tags] and [Documentation] can't use values from arguments, only from global variables. [Timeout], [Setup] and [Teardown] can use [Arguments]. Hence proposed order will work best.

Test code I used for debugging:

*** Variables ***
${global}    global

*** Test Cases ***
Test
    Dynamic Tag    smoke    1

Test 2
    Dynamic Tag    regression    2

*** Keywords ***
Dynamic Tag
    [Arguments]    ${arg}   ${arg2}
    [Documentation]    Doc with ${arg} and ${global}
    [Tags]    my-${arg}
    [Timeout]    ${arg2} min
    Log    ${arg}