1
votes

I run multiple test suites in a single pybot command like this,

pybot suite1.robot suite2.robot suite3.robot

Now, each one of these robot suites add one key,value into a global dictionary (this test variable contains some metrics that needs to be returned to the test-invoker) as,

{ "suite1-res" : xxxx,
"suite2-res" : yyyy,
"suite3-res" : zzzz }

Now, this dictionary needs to be posted to a kafka/any messaging broker. I like this functionality to be written in a post-run hook function/robot case that will be ran only once at the end of all robot cases.

Can this post-run hook functionality be added as a runtime parameter (like suite teardown) instead of passing it as an extra robot test case argument.

1

1 Answers

2
votes

Use a suite file

If you put all of those suites in a folder, you can attach a suite teardown in the folder which will run after all of the child suites finish.

$ mkdir all_tests
$ mv suite*.robot all_tests
$ # edit all_tests/__init__.robot to have a suite teardown
$ pybot all_tests

Use a listener

You can use a listener, which can collect the data and run a post processing step. For example, your tests could attach the metrics as suite metadata which the listener will get when end_suite is called for each suite. The listener can store all of this metadata, then process it when close gets called. For more information see Using the listener interface in the robot framework users guide, and the documentation for Set Suite Metadata keyword in the builtin library.

Write a custom script

For more information, see the section titled Test Suite Directories in the robot framework users guide. For this to work your tests would have to write the dictionary to a file.

Your other choice is to write a simple bash or batch script that runs the pybot command, and then does whatever post processing you want. Your tests will need to somehow make the dictionary data available. For example, you could store the data as suite metadata, and then have the post-processing step pull that data out of the output.xml. Or, your suites could write the data to a file.