user7220195
user7220195

Reputation: 21

Robot framework how to set own name for each test case in data driven tests for report output

Could you please help me how to set own name for each test case into Data Driven to make report more readable.

REAL REPORT EXAMPLE:

Status: FAIL (critical) Message: Several failures occurred:

1) ****************************** FAIL: Wrong value received. Expected: 0 . Actual: 3

2) ****************************** FAIL: Wrong value received. Expected: 0 . Actual: 3

3) ****************************** FAIL: Wrong value received. Expected: 0 . Actual: 3

But it is not clear from the output about details. And I would like to have some details instead of ***************,

THAT I NEED :

Status: FAIL (critical) Message: Several failures occurred:

1) if param is empty FAIL: Wrong value received. Expected: 0 . Actual: 3

2) if param is out of range FAIL: Wrong value received. Expected: 0 . Actual: 3

3) if param is something more FAIL: Wrong value received. Expected: 0 . Actual: 3

I have these detail as ${comment} for each table line into data driven. Could you please help me how to assign it for each test case inside data driven to have more understandable report.

DATA DRIVEN TEST EXAMPLE

st_ddt_test_example
    [Template]    st_ddt_test_example_keyword  
    # comment #                     # value setup #  # value expected #
    if param is empty                   0                    0
    if param is out of range           100                   0
    if param is something more         -8                    0

Upvotes: 2

Views: 969

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385970

Your keyword controls the error that is displayed, so it just needs to include the name as part of the error message.

Here is an example:

*** Keywords ***
Example
    [Arguments]    ${comment}  ${1}    ${2}
    should be equal    ${1}    ${2}
    ...    ${comment}: '${1}' != '${2}'
    ...    False

*** Test Cases ***
Test 1
    [Template]    example
    Test 1.0      a    b
    Test 1.1      b    c
    Test 1.2      c    d

When run, the test yields the following results:

Test 1                                                                | FAIL |
Several failures occurred:

1) Test 1.0: 'a' != 'b'

2) Test 1.1: 'b' != 'c'

3) Test 1.2: 'c' != 'd'

Upvotes: 3

Related Questions