From: Dave Rolsky Date: Tue, 29 Jun 2010 21:47:20 +0000 (-0500) Subject: Incorporate use_ok tests into the test framework. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5c7cd20855d8ea43f6da543e4481d3609ff08113;p=gitmo%2Fmoose-presentations.git Incorporate use_ok tests into the test framework. This provides better feedback to students than just blowing up trying to load the relevant module in the tests. --- diff --git a/moose-class/exercises/t/01-classes.t b/moose-class/exercises/t/01-classes.t index 20f4d6d..9edf657 100644 --- a/moose-class/exercises/t/01-classes.t +++ b/moose-class/exercises/t/01-classes.t @@ -45,7 +45,4 @@ use lib 't/lib'; use MooseClass::Tests; -use Person; -use Employee; - MooseClass::Tests::tests01(); diff --git a/moose-class/exercises/t/02-roles.t b/moose-class/exercises/t/02-roles.t index bb26e15..3c97f15 100644 --- a/moose-class/exercises/t/02-roles.t +++ b/moose-class/exercises/t/02-roles.t @@ -25,7 +25,4 @@ use lib 't/lib'; use MooseClass::Tests; -use Person; -use Employee; - MooseClass::Tests::tests02(); diff --git a/moose-class/exercises/t/03-basic-attributes.t b/moose-class/exercises/t/03-basic-attributes.t index a8c12d3..b04182f 100644 --- a/moose-class/exercises/t/03-basic-attributes.t +++ b/moose-class/exercises/t/03-basic-attributes.t @@ -38,7 +38,4 @@ use lib 't/lib'; use MooseClass::Tests; -use Person; -use Employee; - MooseClass::Tests::tests03(); diff --git a/moose-class/exercises/t/04-method-modifiers.t b/moose-class/exercises/t/04-method-modifiers.t index f617786..f681f72 100644 --- a/moose-class/exercises/t/04-method-modifiers.t +++ b/moose-class/exercises/t/04-method-modifiers.t @@ -45,8 +45,4 @@ use lib 't/lib'; use MooseClass::Tests; -use Document; -use Report; -use TPSReport; - MooseClass::Tests::tests04(); diff --git a/moose-class/exercises/t/05-types.t b/moose-class/exercises/t/05-types.t index efe7ab0..deeca07 100644 --- a/moose-class/exercises/t/05-types.t +++ b/moose-class/exercises/t/05-types.t @@ -24,7 +24,4 @@ use lib 't/lib'; use MooseClass::Tests; -use Person; -use Employee; - MooseClass::Tests::tests05(); diff --git a/moose-class/exercises/t/06-advanced-attributes.t b/moose-class/exercises/t/06-advanced-attributes.t index e6f7271..0c93012 100644 --- a/moose-class/exercises/t/06-advanced-attributes.t +++ b/moose-class/exercises/t/06-advanced-attributes.t @@ -36,8 +36,4 @@ use lib 't/lib'; use MooseClass::Tests; -use Person; -use Employee; -use BankAccount; - MooseClass::Tests::tests06(); diff --git a/moose-class/exercises/t/lib/MooseClass/Tests.pm b/moose-class/exercises/t/lib/MooseClass/Tests.pm index dd0b2ef..74c9edc 100644 --- a/moose-class/exercises/t/lib/MooseClass/Tests.pm +++ b/moose-class/exercises/t/lib/MooseClass/Tests.pm @@ -220,6 +220,8 @@ sub tests06 { { local $Test::Builder::Level = $Test::Builder::Level + 1; + has_meta('Person'); + has_meta('Employee'); has_meta('BankAccount'); no_droppings('BankAccount'); @@ -263,6 +265,9 @@ sub tests06 { sub has_meta { my $class = shift; + use_ok($class) + or BAIL_OUT("$class cannot be loaded"); + ok( $class->can('meta'), "$class has a meta() method" ) or BAIL_OUT("$class does not have a meta() method (did you forget to 'use Moose'?)"); }