robotcodedev / robotcode

RobotFramework support for Visual Studio Code
https://robotcode.io
Apache License 2.0
176 stars 14 forks source link

Can RobotCode Run A Test With --Listener Option? #272

Closed mpserdena closed 2 months ago

mpserdena commented 2 months ago

Please describe. I am trying to run a test via the Testing extension of VSCode using RobotCode, and I am not able to find a setting where I can set --listener as an option when running a test. My tests requires a listener that I created to send an email report and update our test management tool for the result.

I am new to asking a question here in github so I might have missed some information that you need to fully understand my question. I can provide more details to clarify my question if needed.

Thank you!

Desktop (please complete the following information):

GerwinLaagland commented 2 months ago

The answer is yes! I had been trying to figure this out myself as wel last week, and as it turns out it works. You have two options available to you.

Extension settings - Robot:args In the extension settings you have the option to provide additional arguments to be provided to Robot call set by the IDE plugin.

In the option 'Robotcode > Robot:Args' you have the option to add run time commands. Unfortunately, this option is a bit tricky to use. You need to put in the 'flag' you use with Robot, but instead of a space an '=' sign is used:

--listener=RetryFailed:3 image

robotcode-runner with robot.toml Here's a list of things you can put in a robot.toml file to create a profile that works with a listener: https://robotcode.io/latest/cli/config/

In there, you can find 'listener' and 'extend-listener'. Assuming you know how a toml file works. You can put this notation in a profile:

[profiles.tst]
[profiles.tst.extend-listeners]
RetryFailed = ["3"]

You can also put in a generic group not tied to a profile which would work like this:

[listeners]
RetryFailed = ["3"]

This does require that you need to setup things in your toml file however, which is then automatically read by the VSCode IDE, if you want to run it in commandline you'll need to install robotcode-runner via pip.

This listener in this example uses the 'RetryFailed' listener mentioned in the flaky test guide on Robot Framework website: https://docs.robotframework.org/docs/flaky_tests

Hope it helps!

d-biehl commented 2 months ago

Thanks for the answer @GerwinLaagland! This is how I imagine community!!!

mpserdena commented 2 months ago

Wow! This is amazing, option 1 works. I feel truly supported which motivates me to ask more questions instead of spending hours solving the problem by myself.

Thank you @GerwinLaagland and @d-biehl for providing us with this extension.

d-biehl commented 2 months ago

Feel free to ask! 😉