在 Robot Frameowrk 中将长参数拆分为多行

问题描述 投票:0回答:1

我的机器人框架测试中有一些手动步骤,我希望有良好的可读代码。让我们举个例子:

*** Settings ***
Documentation    Hello world example.
Library          Dialogs

*** Test Cases ***
Hello world Test
    [Documentation]    My simple test
    Execute Manual Step    This is first line\nMy second have xxx xxx\nIt seems it is not possible to split this in the code...
    Execute Manual Step    Has it been working in previous step?

我很想拥有类似的东西

*** Settings ***
Documentation    Hello world example.
Library          Dialogs

*** Test Cases ***
Hello world Test
    [Documentation]    My simple test
    Execute Manual Step    This is first line and here goes the second.
    ...                    My second have xxx xxx
    ...                    It seems it is not possible to split this in the code...
    Execute Manual Step    Has it been working in previous step?

但遗憾的是它认为这是三个论点:

Keyword 'Dialogs.Execute Manual Step' expected 1 to 2 arguments, got 3.
robotframework
1个回答
0
投票

@rasjani 在评论中建议了如何做到这一点,结果非常容易实现:

resources/common.robot

*** Settings ***
Library    Dialogs

*** Keywords ***
Tell User
    [Arguments]    @{args}
    ${result} =    Catenate    @{args}
    Execute Manual Step    ${result}

tests/hello.robot

*** Settings ***
Documentation    Hello world example.
Resource         ../resources/common.robot

*** Test Cases ***
Hello world Test
    [Documentation]    My simple test
    Tell User    This is first line and here goes the second:
    ...          We are here splitting this in the code only
    Tell User    This is first line and here goes the second:\n
    ...          My second line\n
    ...          It seems it is working!

© www.soinside.com 2019 - 2024. All rights reserved.