The first script, 'aaa_dbcount.t' is roughly:
print count(*) into "$dbname.count.txt"
And 'zzz_dbcount.t' is roughly:
get count(*) for the table
The tests in zzz_dbcount.t fail when a test that runs after aaa_dbcount.t doesn't clean up after itself. This prevents one run from affecting the next one which can be a very difficult bug to catch otherwise.
When a failure happens I can use the tests to narrow it down. I pick a suspect and run:
make test TEST_FILES="t/aaa_dbcount.t t/suspect.t t/zzz_dbcount.t"
I've thought about doing something that looks at the writable areas of the filesystem too. I bet that would have caught a nasty bug in Krang that I noticed by accident recently - deleting a story deletes the published files (good) but leaves behind empty directories (bad).
So why not wrap this up as a Test:: module? I might but it's a very small amount of code and abstracting "foreach database" and "foreach table" so it'll work across DBD drivers seems hard.