Run a keyword after test execution completed

Hi all,

I have implemented a method (keyword) that sends an email via API and also creates a report in TestRail also via API. The thing is that I want to run this keyword as a teardown (suite?? or smth-like project…??) and not call this method as a separate command in the terminal (like robot -d results tests/ && robot -d results tests/sendEmail.robot).

Is any way where I can run it as a teardown step after the test execution? I would appreciate your answers.

Thanks in advance!

You need to make it a suite teardown of the top level suite. Your top level suite is most likely a directory and in such case you need to add it a suite initialization file (i.e. __init__.robot file). See the User Guide for more information.

1 Like

That’s exactly what I had in mind. I tried it but I missed something, probably on the running command or in the POM, meaning that, where is the correct position to add the init file you mentioned. If it’s possible to give an example it would be great.

Thank you for your reply @pekkaklarck. I really appreciate it!!!

@pekkaklarck as you said, that’s exactly the solution. I managed to do it by adding the init.robot into the tests directory. Thanks again!

1 Like