Using robotframework-metrics as a default report when running in RED editor/Eclipse

482 views
Skip to first unread message

Ritz Kevin Ragel

unread,
Oct 30, 2019, 10:24:55 AM10/30/19
to robotframework-users
Hi Robot Framework Users,

I'm a big fan of adiralashiva8  robot-framework metrics. Is there I way that we can integrate this to Eclipse IDE so every time I run a test, a generated metrics report will appear?


Thank you,
Ritz

Shiva Prasad Adirala

unread,
Oct 30, 2019, 2:09:38 PM10/30/19
to robotframework-users
Thanks Ritz for kind words,

Currently robotframework-metrics doesn't meet your requirements since it post process output.xml on demand to generate custom report

But we have a work around until i come with idea i.e..,

Create a bat/sh file with robot command and robotmetrics (which executes one after other) and execute bat/sh file

So that robotframework-metrics report will be created after execution!

Note: Im not aware on RED usage

Refer Readme.md for sample - https://github.com/adiralashiva8/robotframework-metrics#generate-robotframework-metrics-after-execution

Even im following above approach in my projects

Michał Anglart

unread,
Oct 30, 2019, 5:13:29 PM10/30/19
to robotframework-users
Hi,

I'm from RED team. There is no any dedicated solution however 2 possible way came to my mind when I read your question:

1) It is possible to group multiple launch configuration into a single one which would run them one by one. This is general eclipse feature (google for Eclipse Launch Groups). Theoretically you could create a configuration which would just run robotmetrics after it launched some robot launch configuration. The problem is that having multiple suites you would need to create multiple group configuration or edit the one you have by exchanging the Robot configurations. This looks totally uncomfortable and I'm not sure if this way can be improved.

2) The second way I thought about uses two assumptions: the first one is that robotmetrics only requires output.xml (@Shiva - is it true?) and the second assumes that output_file event of Robot listeners API is called always after output.xml was generated. If both are true as it seems then you can create a simple listener:

import os
import subprocess
import sys


ROBOT_LISTENER_API_VERSION
= 2


def output_file(path):
    command
= ['robotmetrics.exe']
    subprocess
.Popen(command, stdin=subprocess.PIPE)


Then in preferences: Robot Framework -> Launching -> Default Launch Configuration you may add:

--listener /path/to/the/listener/script/above.py


in Additional Robot Framework arguments field. From now each time a new launch configuration will be created it will have this listener added. This way I was able to test it on some simple suite and it seem to work for me:

robotmetrics.png

Michał Anglart

unread,
Oct 30, 2019, 5:24:31 PM10/30/19
to robotframework-users
Additional remark: this listener solution gets a bit complicated if output.xml path is changed with --output command line argument. As of now RED always runs the tests in a process which uses the project directory in which running suite is located as working directory. Then the listener I wrote above would run robotmetrics in the same working directory, so output.xml has to be there. Otherwise you need to change the path too or add some argument for robotmetrics too.


W dniu środa, 30 października 2019 15:24:55 UTC+1 użytkownik Ritz Kevin Ragel napisał:

Shiva Prasad Adirala

unread,
Oct 31, 2019, 2:30:43 PM10/31/19
to robotframework-users
Thanks Michał for detailed info, which helps others to use suggested approach or come up with new approaches

1. robotmetrics requires only output.xml. log, report.html are optional

2. I really liked the second approach you have mentioned, eventhough we have limitations users can modify it respectively

From above thoughts im planning to modify robotmetrics to generate report using listener instead of parsing xml (changes may be part of next version)

Ritz Kevin Ragel

unread,
Nov 3, 2019, 7:58:55 AM11/3/19
to Shiva Prasad Adirala, robotframework-users, Michał Anglart
Hi All,

Apologies for the late response. I was on holiday for the past 3 days. Thank you very much for your wonderful responses. It is indeed very helpful to my inquiry. 


Regards,
Ritz

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/43612db4-404d-452a-a56f-6590a06b4a46%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages