How much do I need to test Moose- and MooseX :: FollowPBP methods?

I want to start strictly performing Test-Driven-Development. However, I was wondering how much I should test the methods created by Moose and MooseX :: FollowPBP. For example, I have the following class:

package Neu::Series;
use Moose;
use MooseX::FollowPBP;

use File::Find::Wanted;

has 'file_regex' => (
    isa=>'RegexpRef',
    is=>'rw',
    default => sub{
                 qr{
                   [A-Z]       #Uppercase letter
                   [a-zA-Z]*   #any letter, any number of times
                   [-]         #dash
                   (           #open capturing parenthesis
                   [0-9]
                   [0-9]
                   [0-9]
                   [0-9]
                   [a-zA-Z]?   #any letter, optional
                   )           #close capturing parenthesis
               }xms;
           },
);


has 'top_dir' => (
    isa=>'Str',
    is=>'rw',
);


has 'access' =>(
    isa=>'Neu::Access',
    is=>'ro',
    required=>1,

);

1;

My current test script is:

use strict;
use warnings;
use Test::More tests => 8;
use Neu::Access;

BEGIN{ use_ok('Neu::Series'); }

can_ok( 'Neu::Series', 'new');
can_ok( 'Neu::Series', 'set_file_regex');
can_ok( 'Neu::Series', 'get_file_regex');
can_ok( 'Neu::Series', 'set_top_dir');
can_ok( 'Neu::Series', 'get_top_dir');
can_ok( 'Neu::Series', 'get_access');

my $access = Neu::Access->new(dsn => 'test');
my $series_worker = Neu::Series->new(access => $access);

isa_ok($series_worker, 'Neu::Series');

Is this enough or too much testing? (That is, in addition to the clearly missing tests for regular expression).

It seemed to me that I saw a web page or other article about this somewhere, but I could not find it today.

+5
source share
4 answers

I would focus on testing my specification. I told Mus that I want him to do the right thing?

:

  • , / , .
  • , .
  • . , . sIf , VII Str Int 7, .
+1

, . , , , , .

Moose , , , Moose, .. , , .

daotoad, , , .

+5

, , - ... , , . , ?

use Test::Deep;
my @attrs = Neu::Series->meta->get_all_attributes;
cmp_deeply( [ map { $_->name } @attrs ], superbagof(qw(file_regex top_dir access)));
+2

, , , , . , , , :

(1) , Moose , . , .

(2) Testing Moose-generated methods is suitable for installing, testing, and supporting your interface. Most agree with that.

Again, thank you all for your input.

EDIT:

This is just a summary of the community. Please read individual answers and comments.

+1
source

All Articles