【问题标题】:robot framework how can i get result after running a method in static API机器人框架在静态 API 中运行方法后如何获得结果
【发布时间】:2014-05-17 20:56:51
【问题描述】:

以下是我在测试用例和套件 (__init__.txt) 文件中引用的 resource.txt。我想在执行映射到静态 API(RobotLibrary)的关键字后获得结果,然后将结果传递回相同的静态 API(RobotLibrary)模块以断言结果。我试图将结果作为状态保存在 RobotLibrary 中,但这可能不起作用,因为 RobotLibrary 是跨多个测试的单个实例?我不介意通过关键字返回结果并将它们作为参数返回给后续调用。

*** Settings ***
Library     ${CURDIR}${/}..${/}src${/}RobotLibrary.py


*** Keywords ***

[return]  ${result_run}

when the configuration file "${filename}" is used to run the journey
        ${result_run}= start journey with config   ${filename}

when the route has a route code of "${routecode}"
        use route code  ${routecode}

journey status should be "${status}"
        assert journey status   ${status}

stop with name "${stopName}" should have an arrival time
        assert stop has arrival time    ${stopName}     ${result}

这不起作用,以下是我在控制台中看到的消息。

(acceptance_test)[root@localhost jsf_acceptance_test]# pybot -L TRACE robot-tests/manual/Mandatory-Delayed-S0-Mandatory-Delayed-S1-329-1/
==============================================================================
Mandatory-Delayed-S0-Mandatory-Delayed-S1-329-1 :: Mandatory-Delayed-S0-Man...
==============================================================================
Mandatory-Delayed-S0-Mandatory-Delayed-S1-329-1.Mandatory-Delayed-S0-Mandat...
==============================================================================
Ensure feedback for stop stop0 on route CGXD                          | FAIL |
Parent suite setup failed:
No keyword with name '${result_run}= start journey with config' found.
------------------------------------------------------------------------------
Ensure feedback for stop stop1 on route CGXD                          | FAIL |
Parent suite setup failed:
No keyword with name '${result_run}= start journey with config' found.
------------------------------------------------------------------------------
Mandatory-Delayed-S0-Mandatory-Delayed-S1-329-1.Mandatory-Delayed-... | FAIL |
Parent suite setup failed:
No keyword with name '${result_run}= start journey with config' found.

2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
Mandatory-Delayed-S0-Mandatory-Delayed-S1-329-1 :: Mandatory-Delay... | FAIL |
Suite setup failed:
No keyword with name '${result_run}= start journey with config' found.

2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
Output:  /home/pycharm/jsf_acceptance_test/output.xml
Log:     /home/pycharm/jsf_acceptance_test/log.html
Report:  /home/pycharm/jsf_acceptance_test/report.html

不知道如何最好地解决这个问题 - 我对机器人框架相对较新,并且发现很难在文档中找到答案。有人对此有任何想法吗?如果您需要,我很乐意用更多信息更新问题。干杯。

【问题讨论】:

    标签: python return keyword robotframework tsv


    【解决方案1】:

    您的测试显示此错误:

    No keyword with name '${result_run}= start journey with config' found.
    

    这意味着机器人测试运行程序在预期关键字的位置遇到了完整的字符串。这可能是因为在=start journey... 之间似乎只有一个空格。尝试添加另一个空格,以便变量和关键字位于测试用例表中的两个单独的单元格中。

    ${result_run}=  start journey with config
    #             ^^ two spaces
    

    如果您改用竖线分隔的格式,这些类型的问题将更容易发现。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-17
      • 2020-10-05
      • 2018-12-27
      • 1970-01-01
      • 2020-10-17
      • 2019-05-30
      • 2022-11-01
      • 2017-04-05
      相关资源
      最近更新 更多