使用 python 测试机器人框架工作中测试套件中每个测试用例的设置和拆卸

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40101372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 23:10:19  来源:igfitidea点击:

Test setup and teardown for each testcase in a test suite in robot frame work using python

pythonrobotframework

提问by shwetha baliga

Hi I'm new to robot frame-work. 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 testcases.

嗨,我是机器人框架的新手。有人可以帮我找出是否有可能对包含大约 20 个测试用例的测试套件中的每个测试用例进行测试设置和拆卸。

Can someone explain this with a example?

有人可以用一个例子来解释这个吗?

回答by Richard Zilahi

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

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}