Subject: | Reporting errors when retrieving object attributes... |
Date: | Thu, 7 Mar 2013 16:21:40 +1100 |
To: | bug-test-simpler [...] rt.cpan.org |
From: | Anthony Marks <marks.anthony [...] gmail.com> |
Dear Damian,
Thank you for Test::Simpler.
I was wondering why, when failing to get an object attribute, the failure
description is returning an 'undef'.
I have the following example code:
package Quote;
use Moose;
use Modern::Perl;
has 'security_desc' => (is => 'ro', required => 1);
has 'asx_code' => (is => 'ro', required => 1);
# DEBUG say "Testing $qbe->security_desc . " (" . $qbe->asx_code . ")";
use Test::Simpler tests => 3;
our $TODO;
# Instantiate a Quote for QBE...
my %QBE_RAW_DATA = (
'security_desc' => 'QBE Insurance Grp',
'asx_code' => 'QBE',
);
my $qbe = Quote->new(%QBE_RAW_DATA);
# Test object and attributes....
ok( defined($qbe) && ref $qbe eq 'Quote', 'Quote->new() works' );
ok( $qbe->security_desc eq 'QBE Insurance Grp', 'get security_desc' );
TODO:{
local $TODO = q{Purposely fail retrieving asx_code ('QBE' != 'EQB')
to see how Test::Simpler reports it.};
ok( $qbe->asx_code eq 'EBQ','get asx_code' );
}
which produces the following output with "prove -v":
object-testing.t ..
1..3
ok 1 - Quote->new() works
ok 2 - get security_desc
not ok 3 - get asx_code # TODO Purposely fail retrieving asx_code ('QBE' !=
'EQB')
# to see how Test::Simpler reports it.
# Failed test at object-testing.t line 30
# $qbe->asx_code
# isn't eq
# 'EBQ'
# Because:
# $qbe-> --> undef
#
# 'EBQ' --> EBQ
ok
All tests successful.
Files=1, Tests=3, 2 wallclock secs ( 0.10 usr + 0.03 sys = 0.13 CPU)
Result: PASS
I was just wondering why the "Because;" does not actually retrieve the
attribute value ('QBE') to highlight the mismatch?
Many thanks,
Anthony Marks
Message body is not shown because sender requested not to inline it.
Message body not shown because it is not plain text.