It's often useful to check that your DBIx::Class classes provide the methods you expect, and no-one has sneakily stolen or broken methods when you weren't looking.
Being lazy I wanted to do this with as little fuss and typing as possible.
Thanks to Test::DBIx::Class::Schema I can do all of the above and would like to share thoughts and musings for the future of the module.
6. Introduction Test::DBIx::Class::Schema Future Finally
Non-Lazy
What about . . . ?
relationships
custom methods
Mostly Lazy DBIx::Class Testing Net-A-Porter
7. Introduction Test::DBIx::Class::Schema Future Finally
Non-Lazy
Decide to test something new?
How many .t files do you need to edit?
More than zero?
Too much work!!
Mostly Lazy DBIx::Class Testing Net-A-Porter
11. Introduction Test::DBIx::Class::Schema Future Finally
An example (config)
# tell it what to test
$schematest->methods({
columns => [ qw( id name ) ],
relations => [ qw( foo ) ],
custom => [ qw( some_method ) ],
resultsets => [ qw( ) ],
});
Mostly Lazy DBIx::Class Testing Net-A-Porter
12. Introduction Test::DBIx::Class::Schema Future Finally
An example (running)
$schematest->run_tests();
Mostly Lazy DBIx::Class Testing Net-A-Porter
13. Introduction Test::DBIx::Class::Schema Future Finally
You get. . .
can ok( @columns )
can ok( @relations )
can ok( @customs ) # row subs
can ok( @resultsets ) # rs subs
Mostly Lazy DBIx::Class Testing Net-A-Porter
14. Introduction Test::DBIx::Class::Schema Future Finally
You also get. . .
$thing->$column called ok
$thing->$relation called ok
test that $column exists in the database
ensure related-source exists
test self.* and foreign.* columns for relationships
test proxied relationships
PASS/FAIL for relationship validity
Mostly Lazy DBIx::Class Testing Net-A-Porter
15. Introduction Test::DBIx::Class::Schema Future Finally
You don’t get
Functional Testing
Mostly Lazy DBIx::Class Testing Net-A-Porter
16. Introduction Test::DBIx::Class::Schema Future Finally
Benefits
only maintaining a list (or three)
lots of sanity checking
find out if someone deletes columns from the database
upgrading ’TDCS’ improves *.t files for free
Mostly Lazy DBIx::Class Testing Net-A-Porter
17. Introduction Test::DBIx::Class::Schema Future Finally
Recommendations
Test one table/class per file
Use Test::Aggregate
Factor out ->new call for $schema
Mostly Lazy DBIx::Class Testing Net-A-Porter
18. Introduction Test::DBIx::Class::Schema Future Finally
In The Real World
on the CPAN since 2008
used in production code since 2009
recent burst of improvements
never used to test empty tables - OOPS!
used to be quite basic
Mostly Lazy DBIx::Class Testing Net-A-Porter
19. Introduction Test::DBIx::Class::Schema Future Finally
Did It Work?
YES!
IMNSHO
Mostly Lazy DBIx::Class Testing Net-A-Porter
20. Introduction Test::DBIx::Class::Schema Future Finally
What Next?
Wishlist
relationship reciprocity
relationships that are coderefs
db columns that aren’t in the schema?
tie-in with DBIx::Class::Schema::Loader
Mostly Lazy DBIx::Class Testing Net-A-Porter