pythonpython-unittestunittest2

Pyunit run tests and build report


I have a collection of tests under one file test_file.py. I can run it normally from the console like this:

python -m unittest test_file

This outputs a small traceback when a test case fails. So what I need to do exactly is.

  1. Run peridically the tests, let's say on crontab (I know how to do this)
  2. send an email report after every run, in order to do this I need to know if all tests went out alright, and in case some of them failed, which ones failed and what the error was, just like the normal pyunit output.

As I said above, I know how to do the cron part and I know how to run the tests, but what do I need or what can I do to accomplish item 2 ?

Maybe a script that manually runs every test and collects the results and then send the email ?

Thank you very much !


Solution

  • if you intend on building out tests in the future, you should consider Jenkins. http://jenkins-ci.org/content/about-jenkins-ci . it can run your tests on a CRON, report results (with an xUnit plugin) per build over time, and conditionally send out an email based on the test results.