1. 创建一个资源文件,命名为myresource.robot
*** Settings ***
*** Variables ***
*** Keywords ***
myResourceFunction
Log To Console "This is from Resource file"
2. 导入测试用例
*** Settings ***
# 和导入一个库相同
Resource myresource.txt
*** Variables ***
*** Test Cases ***
HelloRobot
[Documentation] Hello Robot
Log " Save this message robot"
myfunction
myResourceFunction
*** Keywords ***
myfunction
Log To Console "This is my console message"
3. 运行结果
==============================================================================
Test
==============================================================================
HelloRobot :: Hello Robot ."This is my console message"
."This is from Resource file"
HelloRobot :: Hello Robot | PASS |
------------------------------------------------------------------------------
Test | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================