Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test Setup and Teardown for each test case in a test suite in Robot Framework using python

I'm new to Robot Framework. Can someone help me to find if it's possible to have to a test Setup and a Teardown for each test case in test suite containing around 20 test cases.

Can someone explain this with an example?

like image 498
shwetha baliga Avatar asked Oct 18 '16 06:10

shwetha baliga


People also ask

What is test setup and teardown in Robot Framework?

Test setup and teardown In short, a test setup is something that is executed before a test case, and a test teardown is executed after a test case. In Robot Framework setups and teardowns are just normal keywords with possible arguments. Setup and teardown are always a single keyword.

What is Suite teardown in Robot Framework?

This is a set of keywords or instruction to be executed after the start of test suite or test case execution. We will work on a project setup, where will use both setup and teardown. The opening and closing of browser are the common steps in test cases.

What is teardown test cases?

A teardown test case will execute at the end of your test run within a test folder. Teardown test cases are used to perform post test execution actions. For example, a teardown test case can be used to delete test data generated during test execution.

How do you write test cases in Robot Framework?

To create test case, right-click on the project. Click New Test Case. Enter the name of the test case and click OK. There are 3 tabs shown for the test case created − Edit, Text Edit and Run.


1 Answers

Here's an example. A testsuite containing teardown. You can miss the teardown from each testcase if you want to execute it at last. Please read the corresponding documentation:

http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-setup-and-teardown

*** 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]

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}
like image 168
Richard Zilahi Avatar answered Sep 21 '22 00:09

Richard Zilahi