How to create custom testcase settings like tags in Robot Framework

Viewed 973
*** Test Cases ***
TestCase_ID
    [Documentation]    Clef test
    [Tags]    default_tag
    [link]    this is hyperlink
    Log    This is testing

Use the above code, I want "link:" part shows up in the log.html.

https://i.stack.imgur.com/bMQnq.png

1 Answers

On the Robot Framework Github page there is a feature request 2080 for what you ask. However, this request has been closed at none of the provided use cases could also be implemented using tags.

An alternative that does almost the same is to use the Test Case Message functionality and HTML formatting to generate a section to add links. Below is the example code showing the different options and the total result.

*** Settings ***
Documentation    This is the Suite Level Documentation

Metadata    Version    1.0.0.1           #This the first patch on the initial version.
Metadata    Author     Stack Overflow    #The core developer


*** Test Cases ***
Test Case 1
    [Documentation]     This is the test case documentation
    [Tags]              Test Tag 1

    Set Suite Documentation    Test Level addition to Suite Documenation    append=${true}

    Set Suite Metadata         Test Case 1    A Suite Level Metadata item from the Test Case     append=${true}
    Set Suite Metadata         Link           http://www.microsoft.com    append=${true} 

    Set Test Documentation     My Test Level documentation       append=${true}   
    Set Test Message           *HTML* My Test level Message<br/>             append=${true}

    Comment                    My Test Case Comment
    Log                        My Test Case Log
    Fail
    [Teardown]  Set Jira Link    1234  

*** Keywords ***
Set Jira Link
    [Arguments]    ${jira_Id}
    ${prev_level}    Set Log Level    WARN
    Set Test Message     *HTML* <br/><b>Link:</b> <a href='http://www.jira.com/issue/${jira_Id}'>Jira Issue ${jira_Id}</a><br/>    append=${true}
    Set Log Level    ${prev_level}

With the corresponding result. In this case pay attention to the last line in the code example and the corresponding Message section under testcase on that last line. enter image description here

Related