Warm tip: This article is reproduced from stackoverflow.com, please click
data-driven-tests robotframework

Documentation for each test case when using "Test Template" (Data Driven)

发布于 2020-04-15 10:09:38

When using "Test Template", how can I set [Documentation] to the generated test cases?

I have a workaround for doing it:

*** Settings ***
Test Template    The Test Logic

*** Test Cases ***    arg1   arg2   documentation
Test Case 1            1      a     Doc of test 1
Test Case 2            2      b     Doc of test 2
Test Case 3            3      c     Doc of test 3


*** Keywords ***
The Test Logic
    [Arguments]        ${arg1}     ${arg2}    ${documentation}
    Set Test Documentation      ${documentation}
    Log Many           ${arg1}      ${arg2}

but I think there should be a more native way. I couldn't find such a way. Does anyone know?

Questioner
Erez
Viewed
24
FinlayL 2020-02-03 19:27

I think the best solution available is along the lines of this.

*** Settings ***
Test Template    The Test Logic

*** Test Cases ***    arg1   arg2
Test Case 1            1      a
Test Case 2            2      b
Test Case 3            3      c


*** Keywords ***
The Test Logic
    [Arguments]        ${arg1}     ${arg2}
    Set Test Documentation      Test case covering scenario of ${arg1} and ${arg2}
    Log Many           ${arg1}      ${arg2}