Just a Little 1.

So just a quick one for the Moos-pen today.

I my last post I did create a Test DAD, but then I discovered the problem with doing this is you may spend considerable time just debugging that class to make sure it at least works with any roles it may have to consume and even if you get it to work you may have problems with the roles it is trying to consume.

So I really should test my Database::Accessor::Roles::DAD before I start any load tests,. My basic test I did in a previous post it a good start bur I want to be able to test it before I have says a 100% good DAD. So Moose come to the resque again with MooseX::Test::Role

With this MooseX I can test my role without a 100% perfect consuming class as it just stubs in any subs the role may require. So in 20_dad_load.t I add in

use strict;
++use MooseX::Test::Role;
use Test::More tests => 15;

and then the use;

++ use_ok('Database::Accessor::Roles::DAD');

next I use 'consuming_class' from MooseX::Test::Role to create a test class;

my $da = Database::Accessor->new();
++my $dad_role = consuming_class("Database::Accessor::Roles::DAD",{});

Now I just use the test code from the other day's post, adjusting of course for some new var names ;

foreach my $attribute ($da->meta->get_all_attributes){
if (index($attribute->name(),'_') eq 0);
my $dad_attribute = ucfirst($attribute->name());
ok($dad_role->can($dad_attribute),"Role DAD can $dad_attribute")

and rerun my test case;

ok 2 - use Database::Accessor::Roles::DAD;

ok 3 - use Data::Test;

ok 4 - Role DAD can View

ok 5 - Role DAD can Elements

ok 6 - Role DAD can Conditions

So quick and easy. Now I just have to expand that test case a little to fill in a few holes.


Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations