Antho03
Antho03

Reputation: 49

Robot Framework Set test documentation multiline

I would like use KW "Set test documentation" with multiline with RobotFW The return to the line (\n) does not work with this KW

Someone have solution?

Upvotes: 0

Views: 4857

Answers (2)

Bryan Oakley
Bryan Oakley

Reputation: 386342

Setting multiline documentation is tricky because robot has some odd rules about its documentation. From the user guide section titled Documentation Formatting:

Starting from Robot Framework 2.7.2, all regular text in the formatted HTML documentation is represented as paragraphs. In practice, lines separated by a single newline will be combined in a paragraph regardless whether the newline is added manually or automatically. Multiple paragraphs can be separated with an empty line (i.e. two newlines) and also tables, lists, and other specially formatted blocks discussed in subsequent sections end a paragraph.

In a nutshell, that means that each line needs to end with two newlines.

Example:

*** Variables ***
${var1}  this is var1
${var2}  this is var2

*** Test Cases ***
Example of setting multiline test documentation
    set test documentation
    ...  var1: ${var1}\n\nvar2: ${var2}

The above will appear in log.html like this:

robot log.html test documentation with multiple lines

If your goal is to document the values of variables, robot also supports a simple markup for creating tables. The following example shows how to create a table. In this example I use the ability to append to the documentation rather than replace it:

*** Variables ***
${var1}  this is var1
${var2}  this is var2

*** Test Cases ***

Example 2: documentation with embedded table
    set test documentation  
    ...  | var1 | ${var1} | \n
    set test documentation
    ...  | var2 | ${var2} | \n  append=True

The above will appear in log.html like this:

robot log.html test documentation with embedded table

Upvotes: 1

pankaj mishra
pankaj mishra

Reputation: 2615

I am not sure if we can do that directly, i found a workaround after taking reference from Bryan's reply on this thread.

Testcase level variables in [Documentation] for robot framework

Here multi lines are first mentioned in [Documentation] section and then this section can be used by Set test documentation kw.

*** Variables***
${SystemUnderTest}    Staging

*** Test cases***
Device Test
    Set Test Variable   ${device}    iPhone
    [Documentation]     Device is:
    ...                   System is: ${SystemUnderTest}
    Substitute vars in documentation


*** Keywords ***
Substitute vars in documentation
    ${doc}=  replace variables    ${test documentation}   # This will substitute the variables in documentation with their values , ${test documentation} is an inbuilt keyword which actually parse the content of [Documentation]
    set test documentation    ${doc}    append=True    #now the set test docuemntation will take the multi line input from documentation section

refer below link for further details http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Test%20Documentation

Upvotes: 0

Related Questions