# Run a keyword after test execution completed

**URL:** <https://forum.robotframework.org/t/run-a-keyword-after-test-execution-completed/6014>\
**Category:** Robot Framework\
**Created:** [27 July 2023 08:08 UTC](https://forum.robotframework.org/t/run-a-keyword-after-test-execution-completed/6014 "2023-07-27T08:08:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NikosKoul](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/nikoskoul/32/2512_2.png) [@NikosKoul](https://forum.robotframework.org/u/NikosKoul)\
**Post date:** [27 July 2023 08:08 UTC](https://forum.robotframework.org/t/run-a-keyword-after-test-execution-completed/6014/1 "2023-07-27T08:08:09Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![pekkaklarck](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/pekkaklarck/32/1019_2.png) [@pekkaklarck](https://forum.robotframework.org/u/pekkaklarck)\
**Post date:** [28 July 2023 19:42 UTC](https://forum.robotframework.org/t/run-a-keyword-after-test-execution-completed/6014/2 "2023-07-28T19:42:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![NikosKoul](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/nikoskoul/32/2512_2.png) [@NikosKoul](https://forum.robotframework.org/u/NikosKoul)\
**Post date:** [28 July 2023 22:21 UTC](https://forum.robotframework.org/t/run-a-keyword-after-test-execution-completed/6014/3 "2023-07-28T22:21:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![NikosKoul](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/nikoskoul/32/2512_2.png) [@NikosKoul](https://forum.robotframework.org/u/NikosKoul)\
**Post date:** [29 July 2023 06:23 UTC](https://forum.robotframework.org/t/run-a-keyword-after-test-execution-completed/6014/4 "2023-07-29T06:23:30Z")

</div>

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