Re: Anyone want Test::Class::Moose?

[email protected] (Mark Stosberg)
Newsgroups perl.qa
Message-ID <[email protected]>
> So, does this look useful for folks? Is there anything you would change? (It's trivial to assert plans for classes and the entire test suite rather than rely on done_testing(), but I haven't done that yet).

I would welcome it as an option.

We use Test::Class now, but I have the sense that there's a better
alternative. We have started to load Moose in most cases, so there's no
additional load time penalty for Moose since it's already there.

Some things I like from some alternatives (from reviewing them, not
using them):

I like the declarative style and simple nesting of Test::Spec:

  https://metacpan.org/module/Test::Spec

describe "A User object" => sub {
  my $user;
  before sub {
    $user = User->new;
  };
  describe "from a web form" => sub {
    before sub {
      $user->init_from_tree({ username => "bbill", ... });
    };
    it "should read its attributes from the form";
    describe "when saving" => sub {
      it "should require a unique username";
      it "should require a password";
    };
  };
};

Test::Ika has a similar spirit, but with an option for very readable output:

describe 'MessageFilter' => sub {
    my $filter;

    before_each {
        $filter = MessageFilter->new();
    };

    it 'should detect message with NG word' => sub {
        my $filter = MessageFilter->new('foo');
        expect($filter->detect('hello foo'))->ok;
    };
    it 'should detect message with NG word' => sub {
        my $filter = MessageFilter->new('foo');
        expect($filter->detect('hello foo'))->ok;
    };
};

Check out the TAP-alternative output here:

https://metacpan.org/module/Test::Ika

This is a good idea that I expect to spread: Generating TAP for test
harnesses, but more a readable format when the target is a human reader.

However, I think if I just wanted to mash-up Test::Class and Moose, I
would do something more like this:

package Test::Class::Moose;
use Moose;
use MooseX::NonMoose;
extends 'Test::Class';

####

That way I would have to update our hundreds of test scripts to use a
new syntax. :)  If your project is to be considered a path forward from
Test::Class but with an incompatible syntax, it would be great if it
came with a script to find/replace the old syntax with the replacement.


   Mark
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.