package Test::Setup; use base 'Test::Class'; use Test::Most; # Pulls in strict, warnings, T::More, T::Exception etc. use Schema; # The base of my DBIx::Class classes. sub db_connect : Test(startup) { my $self = shift; my $schema = Schema->connect('dbi:SQLite:dbname=:memory:'); $schema->deploy(); $self->{'schema'} = $schema; }; package Test::Schema::Result::Organisation; use base 'Test::Setup'; use Test::Most; # This does not work! # I expected it to get called after the parent class startup method, but instead it gets called first, # before the startup method in Test::Setup so there is no DB connection and the schema is not defined. # # Test::Schema::Result::Organisation::create_organisation sub create_organisation : Test(startup) { my $self = shift; my $schema = $self->{'schema'}; $self->{'Organisation'} = $schema->resultset('Organisation')->create({ 'name' => 'BigCheeseIndustries', 'description' => 'Test Organisation for the test suite', }); return; };