机器人框架:为整个测试套件运行设置 [英] Robot framework: run setup for an entire test suite

查看:56
本文介绍了机器人框架:为整个测试套件运行设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 ROBOT 中为整个测试套件运行设置,而不是为每个文件单独运行设置?我想在套件的开头运行安装程序,如果安装程序失败,则根本不运行任何测试用例.

Is it possible in ROBOT to run a setup for an entire test suite, rather than running the setup individually for each file? I want to run setup at the beginning of the suite, and if the setup fails, not run any of the test cases at all.

例如,给定以下文件:

*** Settings ***
Test Setup    Setup Fails

*** Test Cases ***
Case1
    Should Be True    1<2

Case2
    Should Be True    2<1

*** Keywords ***
Setup Fails
    Should Be True    2<1

我根本不想执行 Case1 和 Case2.实际上,两者都尝试单独使用 Setup Fails 作为 setup,并且 output.xml 文件具有每个 FAIL 测试用例的状态,并显示一条消息安装失败...".相反,我希望 xml 文件具有失败"套件的状态,并带有安装失败..."消息,并且测试用例要么不包含在内,要么表明它们尚未运行.

I want neither Case1 nor Case2 to execute at all. As it is, both attempt to use Setup Fails as setup individually, and the output.xml file has a status for each test case of FAIL with a message saying "Setup failed...". Instead, I would like the xml file to have a status for the suite of 'FAIL' with a message of "Setup failed..." and the test cases to either not be included or to indicate that they have not been run.

ROBOT 支持吗?

相反,我希望收到一条错误消息

Instead, I would like to receive an error message

推荐答案

Robot 支持 套件设置.例如:

Robot supports suite setups. For example:

*** Settings ***
Suite Setup    Setup Fails

*** Test Cases ***
Case1
    Should Be True    1<2

Case2
    Should Be True    2<1

*** Keywords ***
Setup Fails
    fail    Danger Will Robinson!

以上产生以下结果:

==============================================================================
Example                                                                       
==============================================================================
Case1                                                                 | FAIL |
Parent suite setup failed:
Danger Will Robinson!
------------------------------------------------------------------------------
Case2                                                                 | FAIL |
Parent suite setup failed:
Danger Will Robinson!
------------------------------------------------------------------------------
Example                                                               | FAIL |
Suite setup failed:
Danger Will Robinson!

2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================

这篇关于机器人框架:为整个测试套件运行设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆