【发布时间】:2018-02-09 12:17:19
【问题描述】:
我想运行一个 .robot 文件来测试两个不同的 python 脚本,它们位于不同的目录中。我的 .robot 文件位于/home/alperen/Desktop/scpTest,内容如下:
*** Settings ***
| Library | Process
*** Test Cases ***
| Use Case 1 - Scp Test
| | [Documentation] | This .robot file tests the useCase1ScpTest.py by checking the stdout.
| | [Tags] | use case 1 | critical | scpTest
| | ${result}= | run process | python | /home/alperen/Desktop/scpTest/useCase1scpTest.py
| | Should be equal as integers | ${result.rc} | 0
| | Should be equal as strings | ${result.stdout} | Passed.
| Dummy test
| | [Documentation] | Dummy text
| | [Tags] | foo | bar | runScriptOnRemote
| | ${result}= | run process | python | /home/alperen/Desktop/runScriptOnRemote/masterScript.py
| | Should be equal as integers | ${result.rc} | 0
| | Should be equal as strings | ${result.stdout} | Passed.
如果我运行上面的代码,虚拟测试会失败并显示消息“失败。!= 通过。”因为 masterScript.py 最有可能打印“失败”。但是,如果我将 masterScript.py 与我的 .robot 文件复制到同一目录,则虚拟测试结果通过。谁能帮我理解为什么会这样?有没有办法在不复制 masterScript.py 的情况下通过虚拟测试?提前致谢。
编辑:masterScript.py 在远程机器上运行另一个名为 hello.py(打印“hello world”)的脚本。如果打印“hello world”,则 masterScript.py 文件打印“Passed”。和“失败”。否则。
【问题讨论】:
-
masterScript.py 是做什么的?它确实可以打印“失败”。在一个目录中并“通过”。在另一个。
-
您是否尝试过从两个目录手动启动 masterScript?输出是什么?
-
仅从
/home/alperen/Desktop/runScriptOnRemote运行 masterScript.py 即可。但是,从/home/alperen/Desktop/scpTest运行它会打印以下内容:couldn't read file "hello.py": no such file or directory和“失败”。
标签: testing automated-tests robotframework