Option to execute something after all the test cases are executed

1,489 views
Skip to first unread message

Gowri reddi

unread,
Feb 26, 2016, 4:46:44 AM2/26/16
to robotframework-users
Hi all,

My requirement to look for an option in robot framework to execute something after all the test cases are executed (regardless of Fail or Pass).

Thanks,
Gowri

Gowri reddi

unread,
Feb 26, 2016, 5:50:49 AM2/26/16
to robotframework-users
I mean to say Robot framework has to run one python file after the execution of all test cases. No matter whether all the test cases pass or fail.

Hélio Guilherme

unread,
Feb 26, 2016, 5:58:31 AM2/26/16
to robotframework-users
What you need you can do by using a shell script (command/batch) file.

pybot  Tests.robot
python -c your_prog.py

On Fri, Feb 26, 2016 at 11:50 AM, Gowri reddi <gowri....@gmail.com> wrote:
I mean to say Robot framework has to run one python file after the execution of all test cases. No matter whether all the test cases pass or fail.

--
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 post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Kevin O.

unread,
Feb 26, 2016, 9:09:43 AM2/26/16
to robotframework-users
If for some reason you want the execution to happen while RF is running, you could use a listener.
There is a close method useful for that.

Hélio Guilherme

unread,
Feb 26, 2016, 12:58:03 PM2/26/16
to robotframework-users
I wonder if he only needs a basic Suite Teardown, like in the following example:
*** Settings ***
Suite Teardown    Log    Warning This is the Suite Teardown Warning, with Log Level WARN (Warning!!!)    WARN


You may call a Keyword, or run a Python prog, or whatever, but must be aware that the Report and Log will be generated only after this.

hawkman...@gmail.com

unread,
Feb 26, 2016, 5:38:23 PM2/26/16
to robotframework-users
A suite teardown, as already mentioned, should cover most of what one would want for this.  In my first RF Web App suite I use it to log run stats that were initialized in the suite setup keywords.

But teardown execution does not show in the report, but it does in the log.  If one wants a sub-suite to run at the end of a run a mild hack is use ~ (tilde) as start of file name.  Since RF does a depth-first search by alphabetical order a file in the top of suite called ~last_test_case.robot will get run last and show results in the report.

On Friday, February 26, 2016 at 3:46:44 AM UTC-6, Gowri reddi wrote:

Gowri reddi

unread,
Feb 29, 2016, 12:31:18 AM2/29/16
to robotframework-users
Hi Hawkman,

Could you please send me a sample robot file where  I can run the python file after execution of all test cases.

Thanks,
Gowri

Gowri reddi

unread,
Feb 29, 2016, 8:10:52 AM2/29/16
to robotframework-users
Hi Hawkman,

Thanks for your help.
I am able to run python script from robot framework by using test suite keyword. I need the generation of log files before the execution of python file. But here the case is reverse. could you please help me in this.

Thanks,
Gowri

tgh

unread,
Feb 29, 2016, 8:53:22 AM2/29/16
to robotframework-users
Then, why not using inline both commands:
pybot tests.robot ; python aftertests.py

Ernest Mueller

unread,
Mar 2, 2016, 4:07:41 PM3/2/16
to robotframework-users
Yeah, I ended up writing a wrapper script for use with robot that does a single serial robot run for SUT setup, then a big parallel run of all the real tests, and then a single serial run of SUT teardown (whether the tests all passed or not). It's a little painful mainly because I need to pass information from the setup on to the other runs, but I don't think there's any way to do it without that. 

Ernest


On Friday, February 26, 2016 at 3:46:44 AM UTC-6, Gowri reddi wrote:

hawkman...@gmail.com

unread,
Mar 5, 2016, 4:04:57 PM3/5/16
to robotframework-users


Your requirements keep getting larger on each answer.  I think they are now:
  1. run command after all tests are done
  2. run a python cmd within RF
  3. run after logs have been created
So an RF run needs to produce the output.xml file to be able to produce reports from it.  That file gets finished and closed after the last test.  Once closed the 'report' and 'log' files can be created. So there is no way to run something in an RF run after the logs have been created.

I would use one of the ideas already given and create a wrapper script.  

I currently do this in one run as RF/Selenium exhibits a catastrophic failure after running more than ~600 test cases within one RF run.  (I do not yet know why)  I split up the RF run into two runs based on tags and then run rebot --merge at the end to create one report/log
Reply all
Reply to author
Forward
0 new messages