如何强制机器人框架按顺序选择机器人文件?

rcu*_*her 2 robotframework

我在文件夹(测试)中有机器人文件,如下所示:

tests
   1_robotfile1.robot
   2_robotfile2.robot
   3_robotfile3.robot
   4_robotfile4.robot
   5_robotfile5.robot
   6_robotfile6.robot
   7_robotfile7.robot
   8_robotfile8.robot
   9_robotfile9.robot
   10_robotfile10.robot
   11_robotfile11.robot
Run Code Online (Sandbox Code Playgroud)

现在,如果我执行'/root/users1/power$ pybot root/user1/tests'命令,机器人文件将按以下顺序运行:

tests
   1_robotfile1.robot
   10_robotfile10.robot
   11_robotfile11.robot
   2_robotfile2.robot
   3_robotfile3.robot
   4_robotfile4.robot
   5_robotfile5.robot
   6_robotfile6.robot
   7_robotfile7.robot
   8_robotfile8.robot
   9_robotfile9.robot
Run Code Online (Sandbox Code Playgroud)

我想强制机器人框架按顺序选择机器人文件,如 1,2,3,4,5....

我们有什么选择吗?

Bry*_*ley 5

如果您可以选择重命名文件,您只需要确保前缀是可排序的。对于数字,这意味着它们都应该具有相同的位数。

我建议将您的测试用例重命名为前缀为三或四位数字:

001_robotfile1.robot
002_robotfile2.robot
003_robotfile3.robot
004_robotfile4.robot
005_robotfile5.robot
006_robotfile6.robot
007_robotfile7.robot
008_robotfile8.robot
009_robotfile9.robot
010_robotfile10.robot
011_robotfile11.robot
...
Run Code Online (Sandbox Code Playgroud)

这样,他们将按照您期望的顺序进行排序。