当只有一个案例时,pybot 不制作测试套件
pybot not making test suite when there is a single case
我运行 pybot 使用这个命令,
pybot --argumentfile a
文件 'a' 包含机器人测试用例列表和变量参数,
-v test_type:SUITE
/home/sk/a.robot
/home/sk/b.robot
现在,测试用例是 运行,id 为 s1-s1-t1 和 s1-s2-t2。 Output.xml 包含,
<suite id="s1" name="A & B">
<suite source="/home/sk/a.robot" id="s1-s1" name="A">
<test id="s1-s1-t1" name="Log Test">...</test>
现在,我删除了一个案例,文件 'a' 只有一个案例,因为,
-v test_type:SUITE
/home/sk/a.robot
Output.xml包含,
<suite source="/home/sk/a.robot" id="s1" name="A">
<test id="s1-t1" name="Log Test">
-----------------</test></suite>
Robot 不再在父套件 s1 下创建子套件 s1,而是 运行 创建 ID 为 s1-t1 的测试用例。这种创建测试套件的不一致方式使 DOM 解析 output.xml 对我来说很困难。
如果它是 运行 且具有 --argumentfile
选项,是否有办法强制机器人始终创建测试套件。
当您 运行 只有一个套件时,您无法让机器人自动添加这个特殊的 top-level 套件。只有当你 运行 两个或更多套件时,Robot 才会自动生成此顶级套件。
机器人框架用户指南中标题为 Specifying test data to be executed:
的部分提到了此功能
It is also possible to give paths to several test case files or
directories at once, separated with spaces. In this case, Robot
Framework creates the top-level test suite automatically, and the
specified files and directories become its child test suites.
注意:这与参数文件的使用完全无关。如果将参数直接放在命令行上,您将获得完全相同的结果。
重新思考如何 运行 套房
一个解决方案是开始测试 运行 一个文件夹:将所有套件放在一个文件夹中,并且始终 运行 只是那个文件夹。这将始终为您提供一致的 top-most 套件。您仍然可以指定单个套件,但要指定套件名称而不是文件名
例如,而不是这个:
-v test_type:SUITE
/home/sk/a.robot
你会这样做:
-v test_type:SUITE
--suite a
/home/sk
这有一个额外的好处,您可以创建一个 top-level 套件初始化文件(例如:/home/sk/__init__.robot
),该文件将始终得到应用。请参阅机器人框架用户指南中的 Initialization files。
注意:如果您在 /home/sk
中除了测试套件之外还有其他东西,您可能希望将所有测试移动到 sub-folder(例如: /home/sk/tests/a.robot
, /home/sk/tests/b.robot
, 等等)
我运行 pybot 使用这个命令,
pybot --argumentfile a
文件 'a' 包含机器人测试用例列表和变量参数,
-v test_type:SUITE
/home/sk/a.robot
/home/sk/b.robot
现在,测试用例是 运行,id 为 s1-s1-t1 和 s1-s2-t2。 Output.xml 包含,
<suite id="s1" name="A & B">
<suite source="/home/sk/a.robot" id="s1-s1" name="A">
<test id="s1-s1-t1" name="Log Test">...</test>
现在,我删除了一个案例,文件 'a' 只有一个案例,因为,
-v test_type:SUITE
/home/sk/a.robot
Output.xml包含,
<suite source="/home/sk/a.robot" id="s1" name="A">
<test id="s1-t1" name="Log Test">
-----------------</test></suite>
Robot 不再在父套件 s1 下创建子套件 s1,而是 运行 创建 ID 为 s1-t1 的测试用例。这种创建测试套件的不一致方式使 DOM 解析 output.xml 对我来说很困难。
如果它是 运行 且具有 --argumentfile
选项,是否有办法强制机器人始终创建测试套件。
当您 运行 只有一个套件时,您无法让机器人自动添加这个特殊的 top-level 套件。只有当你 运行 两个或更多套件时,Robot 才会自动生成此顶级套件。
机器人框架用户指南中标题为 Specifying test data to be executed:
的部分提到了此功能It is also possible to give paths to several test case files or directories at once, separated with spaces. In this case, Robot Framework creates the top-level test suite automatically, and the specified files and directories become its child test suites.
注意:这与参数文件的使用完全无关。如果将参数直接放在命令行上,您将获得完全相同的结果。
重新思考如何 运行 套房
一个解决方案是开始测试 运行 一个文件夹:将所有套件放在一个文件夹中,并且始终 运行 只是那个文件夹。这将始终为您提供一致的 top-most 套件。您仍然可以指定单个套件,但要指定套件名称而不是文件名
例如,而不是这个:
-v test_type:SUITE
/home/sk/a.robot
你会这样做:
-v test_type:SUITE
--suite a
/home/sk
这有一个额外的好处,您可以创建一个 top-level 套件初始化文件(例如:/home/sk/__init__.robot
),该文件将始终得到应用。请参阅机器人框架用户指南中的 Initialization files。
注意:如果您在 /home/sk
中除了测试套件之外还有其他东西,您可能希望将所有测试移动到 sub-folder(例如: /home/sk/tests/a.robot
, /home/sk/tests/b.robot
, 等等)