如何从以命令行列表参数作为输入的eclipse中执行Robot测试用例? [英] How to execute Robot testcase from eclipse which takes command line list arguments as input?

查看:66
本文介绍了如何从以命令行列表参数作为输入的eclipse中执行Robot测试用例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个机器人测试用例,它从命令行获取输入列表.我从命令行运行了测试用例,它成功执行.当我从Eclipse运行相同的脚本时,所有问题都来了,测试用例失败并给出了控制台消息-

I have written a Robot test case which takes input list from command line. I ran the test case from command line and it executed successfully. All the issue comes when i run the same script from Eclipse, the test case fails and gives a console message -

列表变量'@ {list_of_vars}'在索引0中没有任何项目."

'List variable '@{list_of_vars}' has no item in index 0.'

下面是我的代码-

[Tags]    TestCLI   
    @{list_of_vars}    Split String    ${my_vars}
    Log   @{list_of_vars}[0]
    Log   @{list_of_vars}[1]

用于从命令行执行测试用例的语法:

Syntax used for executing test case from command line:

python -m robot -v my_vars:one,two -E space:, -t "TestCLI" C:\Users\user1\eclipse-workspace\RobotTests\robot\firstTest.robot

我知道@ {list_of_vars}从Eclipse运行测试用例时正在寻找输入元素.我使用运行"和启动过程"关键字来启动命令行,但无法成功.有什么办法可以解决该错误并从Eclipse运行相同的脚本.

I understood that @{list_of_vars} is looking for input elements when running the test case from eclipse. I have used Run and Start Process keywords to start the command line and couldn't succeed. Is there any way to resolve the error and run the same script from eclipse.

其他详细信息-

  1. 机器人框架版本-3.0.2,
  2. Eclipse氧气
  3. Python版本3.6.4,
  4. RED编辑器0.8.3.2018xxx

推荐答案

运行示例时,我无法复制您的结果.相反,我观察到了期望的行为.下面是我使用的设置.

When running your example I was not able to replicate your results. Instead I observe the desired behavior. Below are the settings I used.

firstTest.robot

*** Settings ***
Library    String    

*** Test Cases ***

TC
    [Tags]    TestCLI   
    Log    ${my_vars}
    @{list_of_vars}    Split String    ${my_vars}
    Log   @{list_of_vars}[0]
    Log   @{list_of_vars}[1]

需要在运行配置中设置其他命令行变量 -v my_vars:one,two -E space:.

The additional command line variables -v my_vars:one,two -E space:, need to be set on the run configuration.

这将导致以下消息日志:

Starting test: RunWithVars.firstTest.TC
20180404 20:45:06.445 : INFO : one two
20180404 20:45:06.447 : INFO : @{list_of_vars} = [ one | two ]
20180404 20:45:06.448 : INFO : one
20180404 20:45:06.449 : INFO : two
Ending test: RunWithVars.firstTest.TC

控制台日志.我将命令分成几行,并删除了一些-listener 文件夹路径,以提高可读性.

And console log. I've seperated the command into seperate lines and removed some of the --listener folder path for readability.

Command: C:\Python\RF_P27\Scripts\python.exe 
 -m robot.run 
 --listener C:\Users\..\TestRunnerAgent.py:51805 
 -s RunWithVars.FirstTest 
 -v my_vars:one,two -E space:, C:\TA\W\StackOverflow\RunWithVars
Suite Executor: Robot Framework 3.0.2 (Python 2.7.13 on win32)
==============================================================================
RunWithVars                                                                   
==============================================================================
RunWithVars.firstTest                                                         
==============================================================================
TC                                                                    | PASS |
------------------------------------------------------------------------------
RunWithVars.firstTest                                                 | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
RunWithVars                                                           | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output:  C:\TA\W\StackOverflow\RunWithVars\output.xml
Log:     C:\TA\W\StackOverflow\RunWithVars\log.html
Report:  C:\TA\W\StackOverflow\RunWithVars\report.html

这篇关于如何从以命令行列表参数作为输入的eclipse中执行Robot测试用例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆