Hello, all,
I'm using Test::More and Moose.
My minimal Moose class looks a little like this:
package Foo;
use Moose;
has 'first_name' => ( is => 'rw', isa => 'Str', required => 1);
has 'last_name' => ( is => 'rw', isa => 'Str', required => 1);
no Moose;
1;
My new.t file has the following:
use Foo;
use Test::More tests => 2;
ok( my $foo = Foo->new(
first_name => 'Joe',
last_name => 'Average',
)
);
ok( my $incomplete = Foo->new(
first_name => 'Joe',
)
);
Now, I know the second test will fail; it's what I'm testing for. What I don't know is, how do I tell Test::More that failure is what I'm hoping for? I've tried wrapping it in an eval and testing $@, but it still reports as a failure.
Am I missing something glaringly obvious here?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.