【问题标题】:Templated robot test case doesn't always run Setup and Teardown keywords模板化机器人测试用例并不总是运行 Setup 和 Teardown 关键字
【发布时间】:2013-09-24 19:23:33
【问题描述】:

我希望每次执行模板化测试时都会运行 Test Setup 和 Test Teardown 关键字,但似乎并非如此。这是我的测试套件的简化版本,它演示了我在说什么。我像pybot template-problem.txt 一样运行它。请注意,生成的日志文件显示我的 Test Case SetupTest Case Teardown 关键字每个只运行一次。

*** Settings ***
Test Setup        Test Case Setup
Test Teardown     Test Case Teardown

*** Test Cases ***
Look for All Possible Outputs from the System Under Test
    [Template]    Look for Specific Output
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    P
    Q
    R
    S
    T
    U
    V
    W
    X
    Y
    Z

*** Keywords ***
Test Case Setup
    Comment    Setting up before the test case runs

Test Case Teardown
    Comment    Cleaning up after the test case finishes

Look For Specific Output
    [Arguments]    ${output}
    Comment    Pretending to look for a specific output...
    Log    ${output}

【问题讨论】:

    标签: python robotframework


    【解决方案1】:

    来自Robot Framework documentation on test templates

    而普通测试用例的主体是由关键字构成的 及其可能的参数,带有模板的测试用例只定义 模板关键字的参数。

    因此,使用模板只是将测试用例转换为:

    Look for All Possible Outputs from the System Under Test
        Look for Specific Output    A
        Look for Specific Output    B
        Look for Specific Output    C
        ...
    

    即它仍然只是一个测试用例,用不同的参数连续多次调用相同的关键字。

    【讨论】:

    • 啊。所以它是测试主体的模板,而不是从模板生成完整测试用例的方法。谢谢!
    猜你喜欢
    • 2016-05-15
    • 2020-05-07
    • 2019-08-02
    • 1970-01-01
    • 2015-04-24
    • 1970-01-01
    • 2015-09-09
    • 1970-01-01
    • 2018-02-09
    相关资源
    最近更新 更多