【发布时间】:2020-11-11 19:13:03
【问题描述】:
我想使用 Robot 框架自动执行下一个命令在 cmd 中执行的步骤:
docker-compose logs --no-color --tail=1 the-server
上一条命令的输出将是docker-compose.yml文件中名为the-server的服务器的日志。
我想检查这个命令的响应是否有字符串Started the-server之后,检查服务器是否启动。
我正在使用下一个机器人文件:
*** Settings ***
Library Process
Library OperatingSystem
Suite Setup log running on ${properties.hostname}
Suite Teardown Terminate All Processes kill=True
Variables C:/Users/TheUser/Desktop/CheckOutRegression/properties.py
*** Test Cases ***
Check if the-server is up
${result} Wait Until Keyword Succeeds 10x 20s Check The-Server
*** Keyword ***
Check The-Server
${resultOfcmd} Run Process docker-compose logs --no-color --tail\=1 the-server shell=yes cwd=${properties.pathToDocker}
Should Contain ${resultOfcmd} 'Started the-server' PASS
Log To Console ${resultOfcmd}
测试用例总是因错误而失败:
重试 10 次后,关键字“检查服务器”失败。最后一个错误是:TypeError: 'ExecutionResult' object is not iterable
我也不确定变量{resultOfcmd} 是否包含命令docker-compose logs --no-color --tail\=1 the-server 的输出。
谁能帮忙?
【问题讨论】:
标签: docker process robotframework