1
votes

I run pybot using this command,

pybot --argumentfile a

File 'a' has the list of robot test cases and variable arguments as,

-v test_type:SUITE
/home/sk/a.robot
/home/sk/b.robot

Now, the test cases are run with ids, s1-s1-t1 and s1-s2-t2. Output.xml contains,

<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>

Now, i removed one case and file 'a' has only one case as,

-v test_type:SUITE
/home/sk/a.robot

Output.xml contains,

<suite source="/home/sk/a.robot" id="s1" name="A">
<test id="s1-t1" name="Log Test">
      -----------------</test></suite>

Robot doesn't create the sub-suites s1 under parent suite s1 any more and instead it runs the testcase with ids s1-t1. This inconsistent way of creating test suites is making DOM parsing of output.xml difficult for me.

Is there a way to force robot to always create a test suite if it is run with --argumentfile option.

1

1 Answers

2
votes

You cannot get robot to automatically add this special top-level suite when you run only a single suite. Only when you run two or more suites will Robot automatically generate this top level suite.

This feature is mentioned in the robot framework user's guide, in a section titled 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.

Note: this has absolutely nothing to do with the use of argument files. You'll get exactly the same results if you put the arguments directly on the command line.

Rethinking how you run suites

One solution is to start your test run one folder up: put all of your suites inside a single folder, and always run just that single folder. This will always give you a consistent top-most suite. You can still specify individual suites, but by suite name rather than file name

For example, instead of this:

-v test_type:SUITE
/home/sk/a.robot

You would do this:

-v test_type:SUITE
--suite a
/home/sk

This has an added benefit that you can create a top-level suite initialization file (eg: /home/sk/__init__.robot) that will always get applied. See Initialization files in the robot framework user's guide.

Note: If you have other things in /home/sk besides test suites, you might want to move all of your tests to a sub-folder (eg: /home/sk/tests/a.robot, /home/sk/tests/b.robot, etc)