如何在所有测试套件之前运行设置?

huangapple go评论97阅读模式
英文:

How to run a setup before all test suites?

问题

我知道RobotFramework中有设置(Setup)和测试套件设置(Suite Setup),但如果我想在执行测试之前执行某些操作,而且这个测试套件引用了多个测试套件,该如何实现呢?

像下面这样如何实现所有测试设置(All Test Setup)和所有测试拆卸(All Test Teardown):

**所有测试设置(All Test Setup)**
    测试套件设置(Suite Setup)
        用例设置(Case Setup)
            用例1
        用例拆卸(Case Teardown)
        用例设置(Case Setup)
            用例2
        用例拆卸(Case Teardown)
    测试套件拆卸(Suite Teardown)
    测试套件设置(Suite Setup)
        用例设置(Case Setup)
            用例1
        用例拆卸(Case Teardown)
        用例设置(Case Setup)
            用例2
        用例拆卸(Case Teardown)
    测试套件拆卸(Suite Teardown)
**所有测试拆卸(All Test Teardown)**

注意:上述内容已经按照中文进行翻译,只包括您提供的需要翻译的部分。

英文:

I know that there are Setup and Suite Setup in RobotFramework, but if I want to do something before a test, and this test package refers to multiple Test Suites. How do I achieve it.

Like below how to achieve all Test Setup & all Test Teardown

**All Test Setup**
    Suite Setup
        Case Setup
            Case1
        Case Teardown
        Case Setup
            Case2
        Case Teardown
    Suite Teardown
    Suite Setup
        Case Setup
            Case1
        Case Teardown
        Case Setup
            Case2
        Case Teardown
    Suite Teardown
**All Test Teardown**

答案1

得分: 1

同样地,所有的目录都是测试套件1。因此,对于全局的设置和清理操作,您需要为顶层测试套件定义一个“套件设置”和“套件清理”:即包含所有测试目录的目录。要做到这一点,创建一个__init__.robot文件并在该目录中定义设置和清理操作。

英文:

Similarly than all files, all directories are test suites. Thus, for global setup and teardown, you will have to define a Suite setup and Suite teardown for your top level test suite: the directory which holds all your test directories. To do this, create __init__.robot file to this directory and define the setup and teardown there.

huangapple
  • 本文由 发表于 2023年7月13日 21:41:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76680062.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定