in reply to A Framework for automated DB testing

I use mysqldump to do my testing. If I already have a database I start with
mysqldump -d database > test_database.schema echo create database test_database | mysql mysql test_database < test_database.schema
Now when I am creating/updating tests I can:
mysqldump test_database > test_database.schema
Then I can recursively do
mysql test_database < test_database.schema mysql test_database < alter_database mysql test_database < add_test_data ./Build test
until I am happy with the tests. Then when I install of the new code base I should only need to run
mysql database < alter_database
as an additional step. I then use this code to make sure that the databases have the same structure.
use Algorithm::Diff; my @a = grep( !/Database:/, split('\n', `mysqldump -d tasker`)); my @b = grep( !/Database:/, split('\n', `mysqldump -d test_tasker`)); my $diff = Algorithm::Diff->new( \@a, \@b ); while($diff->Next()) { next if $diff->Same(); next if /Database:/; print "< $_\n" for $diff->Items(1); print "> $_\n" for $diff->Items(2); }
-- gam3
A picture is worth a thousand words, but takes 200K.

Replies are listed 'Best First'.
Re^2: A Framework for automated DB testing
by Mutant (Priest) on Nov 03, 2006 at 15:02 UTC
    Hi.. that's similar to what I'm doing now.. it just seems a little long winded to me, especially when changing the schema... but I guess there's not really an easier way of doing it.