How to organize live data integrity tests and code unit tests?

Posted by karlthorwald on Stack Overflow See other posts from Stack Overflow or by karlthorwald
Published on 2010-04-25T08:00:57Z Indexed on 2010/04/25 8:13 UTC
Read the original article Hit count: 303

I have several files with code testing code (which uses a "unittest" class).

Later I found it would be nice to test database integrity also. I put this into a separate directory tree. (Things like the keys have correct format, parent and child nodes are pointing correctly and such.)

I use the same unittest class for the integrity tests.

Now I wonder if it makes really sense to keep this separate. To test the integrity of data I often duplicate parts of code that I use to test the code that handles the data.

But it is not the same. The code tests use test databases (that get deleted after each test) and the integrity tests connect to the live data and analyze it. The integrity tests I want to call from cron and send an alarm if something happens in the live database.

How would you handle that? Are there standards for such a setup? What is your experience?

My tendency is to put everything in the same file, which would result in the code tests also being executed by the cron on the production environment.

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about automated-tests