如何强制 Robot Framework 只初始化我的自定义库一次

How to force Robot Framework to initialize my custom library only once

我在 Python 中创建了一个自定义库,__init__ 模块中的一个函数是 self.create_new_folder()

Robot Framework 初始化库两次:

我可以检查文件夹是否已经存在,但我想知道是否有办法强制 Robot 只初始化库一次。

如果您将 ROBOT_LIBRARY_SCOPE 设置为 GLOBAL,该库将为测试 运行.

恰好实例化一次

来自文档:

GLOBAL - Only one instance is created during the whole test execution and it is shared by all test cases and test suites. Libraries created from modules are always global.

示例:

class ExampleLibrary:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-library-scope