我的测试步骤创建了 5 个工作线程来将文件上传到服务器,并为每个线程返回服务器 HTTP 响应代码。
我想将这些附加到每个步骤的响应代码列表中。
TC001_Single_User_Upload
[Documentation] Uploading single file by single user
${result} single user test file upload test_file.txt test1 test
Append To List @{RESPONSE_LIST} ${result}
${result} single user test file upload test_file.txt test1 test
Append To List @{RESPONSE_LIST} ${result}
log variables
log many @{RESPONSE_LIST}
我当前的日志文件显示:
20171127 13:59:01.911 - INFO - @{RESPONSE_LIST} = [ ]
20171127 13:59:01.911 - INFO - @{result} = [ <Response [201]> | <Response [201]> | <Response [201]> | <Response [201]> | <Response [201]> ]
问:为什么我的@{RESPONSE_LIST} 是空的?
最佳答案
Append to list
的第一个参数需要是一个列表对象。当您使用 @
,这就像您将列表中的每个元素都作为一个新参数一样。
解决方法是更改@
至 $
:
Append To List ${RESPONSE_LIST} ${result}
来自 robot framework user guide :
When a variable is used as a scalar like ${EXAMPLE}, its value will be used as-is. If a variable value is a list or list-like, it is also possible to use as a list variable like @{EXAMPLE}. In this case individual list items are passed in as arguments separately.
关于robotframework - 将返回值附加到 Robot Framework 中的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47520868/