Testing 运行位于不同目录中的两个不同python脚本的测试用例

Testing 运行位于不同目录中的两个不同python脚本的测试用例,testing,automated-tests,robotframework,Testing,Automated Tests,Robotframework,我想运行一个.robot文件来测试两个不同的python脚本,它们位于不同的目录中。My.robot文件位于/home/alperen/Desktop/scpTest中,如下所示: *** Settings *** | Library | Process *** Test Cases *** | Use Case 1 - Scp Test | | [Documentation] | This .robot file tests the useCase1ScpTest.py by checki

我想运行一个.robot文件来测试两个不同的python脚本,它们位于不同的目录中。My.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.
如果我运行上面的代码,虚拟测试将失败,并显示一条消息“Failed.!=Passed”。因为masterScript.py很可能打印“Failed”。但是,如果我将masterScript.py复制到与.robot文件相同的目录,虚拟测试结果将失败。谁能帮我理解为什么会这样?有没有办法通过虚拟测试而不复制masterScript.py?提前谢谢


编辑:masterScript.py在远程计算机上运行另一个名为hello.py的脚本(打印“hello world”)。如果打印了“hello world”,则masterScript.py文件将打印“已通过”和“失败”。否则。

使用--pythonpath开关运行robot,将其指向masterScript.py路径。这不是最优雅的解决方案,但它可以工作

我修改了masterScript.py,其中包括

command = [ "python", "hello.py" ]

由于Psytho的建议,将“hello.py”更改为其完整目录,类似于
“/home/alperen/Desktop/runScriptOnRemote/hello.py”
的操作奏效了。

masterScript.py做了什么?它确实可以在一个目录中打印“Failed.”,在另一个目录中打印“Passed.”。您是否尝试从两个目录手动启动masterScript?输出是什么?从
/home/alperen/Desktop/runScriptOnRemote
运行masterScript.py就可以了。但是,从
/home/alperen/Desktop/scpTest
运行它会打印以下内容:
无法读取文件“hello.py”:没有这样的文件或目录
并且“失败”