Question

It's about time I wrote a functionality test for Dist::Zilla::Plugin::Catalyst. But I realized that I haven't a clue on where to start. I know that I have to have a custom minting profile recognized by my test suite, and that I'm probably going to just test to make sure that all the right files are output with suitable perms. I'm not at all sure what DZ module to you use for including the minting profile, or how to then start a mint, and then check the output ( because I suspect that it's going to use a temp directory ).

Could someone give me some pointers? are there any other minting modules, that have tests?

Was it helpful?

Solution

The official Dist::Zilla tutorial now has a page on writing and testing new plugins. This covers plugins in general, not minting plugins specifically, but there's nothing particularly special or different about doing it for minting plugins. You can see t/minter., as suggested, to see just how similar it is.

Test::DZil is now shipped with Dist::Zilla and installed for use by other plugins, and I use it for testing all my non-core plugins.

OTHER TIPS

Here's a very basic Test file for a minter.

#!/usr/bin/perl
use strict;
use warnings;
use Dist::Zilla::Tester;
use Test::More;
use Path::Class;

my $tzil = Minter->_new_from_profile(
    # which profile to run e.g. dzil new  -p
    [ Default => 'default' ],
     # app name
    { name => 'CatApp', },
    # location of whats esessntially your tests ~/.dzil
    { global_config_root => dir('corpus/mint')->absolute },
);

# same as running dzil new
$tzil->mint_dist;

# mint root, obviously getting the location of the temporary repo creation
my $mr   = dir( $tzil->tempdir )->subdir('mint');

# test to see if CatApp.pm exists
ok( -e $mr->subdir('lib')->file('CatApp.pm'), 'CatApp.pm exists');
done_testing

of course for many a real test you'll also want to read the minted files. This can be done with $tzil->slurp_file('file');.

Not much is different for testing a minted dist from a regular Dist::Zilla::Tester test, so you might wish to read the blog I wrote on writing a simple Dist::Zilla::Tester test.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top