use Test::More tests => 3; use Test::Exception; use strict; use warnings; { package Foo::Service; use Moose; with qw/MooseX::Service/; } my $service = Foo::Service->new; throws_ok { $service->register (hello => 0) } qr/expects a code reference/,'requires coderef'; lives_ok { $service->register (hello => sub { 'world' }) } 'register'; is ($service->hello,'world','retrieve');