shwetha baliga
shwetha baliga

Reputation: 27

How to get current test case(s) status pass/failed in Robot Framework

I have used ${TEST STATUS} (Automatic variable) for getting the status giving error.

Upvotes: 1

Views: 12524

Answers (2)

Jagrut Trivedi
Jagrut Trivedi

Reputation: 1319

you can use that variable only in teardown section. like below example. robot is maintaining two levels "test levels" and "suit levels". inside test level there is another two things called "setup" and "teardown". setup means before executing every testcase it will run. and teardown means after executing every testcase it will run. In below example before executing Default_values, Overridden setup, No_teardown,etc. testcases Open_Application will run and after exiting the testcases Close Application will run. you can use that automatic variable in the tear down section only as described in docs and demonstated in the No_teardown testcase. In the No_teardown testcase it is checking whether it is true or not. you can change anything according to your need.

*** Settings ***
Test Setup       Open Application    App A
Test Teardown    Close Application

*** Test Cases ***
Default values
    [Documentation]    Setup and teardown from setting table
    Do Something

Overridden setup
    [Documentation]    Own setup, teardown from setting table
    [Setup]    Open Application    App B
    Do Something

No teardown
    [Documentation]    Default setup, no teardown at all
    Do Something
    [Teardown]    Should Be True      '${TEST STATUS}' == 'True'

No teardown 2
    [Documentation]    Setup and teardown can be disabled also with special value NONE
    Do Something
    [Teardown]    NONE

Using variables
    [Documentation]    Setup and teardown specified using variables
    [Setup]    ${SETUP}
    Do Something
    [Teardown]    ${TEARDOWN}

This example is modified version of this robot docs link:- http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-setup-and-teardown

Hope this will remove your doubts.

Upvotes: 5

Richard Zilahi
Richard Zilahi

Reputation: 692

There is a global variable called ${TEST_STATUS}. You can use it in teardown section.

See the corresponding part Automatic Variables in the documentation.

http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#id514

Upvotes: 1

Related Questions