[英]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. 测试配置为记录stdout
和stderr
,只要测试通过就可以正常工作,但是即使在失败之前打印输出,测试失败时也没有记录。
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.