简体   繁体   English

当测试失败时,机器人框架在log.html内没有输出

[英]Robot framework no output inside log.html when tests fail

I have a python script which I run as a test in robot framework. 我有一个python脚本,我在机器人框架中作为测试运行。 The test is configured to log the stdout and stderr which works fine as long as the test pass but I get no logs when test fails even if the output is printed before the failure. 测试配置为记录stdoutstderr ,只要测试通过就可以正常工作,但是即使在失败之前打印输出,测试失败时也没有记录。

Is there any way to get the stdout even if the tests fails. 即使测试失败,有没有办法获得stdout

My robot file: 我的机器人文件:

*** Settings ***
Library   Process


*** Test Cases ***
First test
    ${result} =     Run Process     python    createCommunityTest/createCommunityTest.py
    Should Be Equal As Integers     ${result.rc}    0    
    Log     ${result.stderr} 
    Log     ${result.stdout}

test script snippet 测试脚本片段

        if res.status == 201: 
            sys.exit(0)
        else:
            print("ERRRROR")
            sys.exit(1)

The problem is that you are calling Log after the test has failed. 问题是您在测试失败调用Log When you check the return code and the return code is not zero, the test immediately stops running any other statements. 当您检查返回代码并且返回代码不为零时,测试会立即停止运行任何其他语句。

You can solve this simply by calling the Log keyword before checking the return code. 您可以在检查返回代码之前通过调用Log关键字来解决此问题。

Log     ${result.stderr} 
Log     ${result.stdout}
Should Be Equal As Integers     ${result.rc}    0  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python不会登录Robot框架log.html - Python doesn't log into Robot framework log.html 如何在log.html和output.xml中向ROBOT Framework测试统计信息添加一些外部链接? - How to add some external links to ROBOT Framework Test Statistics in log.html and output.xml? 有没有办法在机器人框架中测试完成后在电子邮件中发送log.html,report.html和output.xml? - Is there a way to send log.html,report.html and output.xml in email after test completion in robot-framework? 通过 Rebot 模型在机器人框架中生成两个 log.html 文件时出错 - error while generating two log.html files in robot framework by Rebot model 像机器人关键字一样将 Python 函数记录到 log.html - Logging Python function to log.html like robot keywords 使用 API 时使 log.html 更详细 - Making the log.html more verbose when using the API 机器人框架:将机器人框架与MySql连接时,出现“ FAIL:NoSectionError:No section:'default'”错误 - Robot Framework :I am getting “FAIL : NoSectionError: No section: 'default' ” error when i connect the Robot Framework with MySql 在Robot Framework中添加日志文件 - tail a log file in Robot Framework 记录字典以在“机器人框架”中进行控制台 - Log dictionary to console in `robot framework` 无法打印 Robot Framework 中的日志 - Unable to print the log in Robot Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM