1use 5.014; 2 3use lib 't/lib'; 4 5use strict; 6use warnings; 7 8use Test::Auto; 9use Test::More; 10 11=name 12 13Test::Auto::Plugin 14 15=abstract 16 17Test-Auto Plugin Class 18 19=includes 20 21method: tests 22 23=synopsis 24 25 package Test::Auto::Plugin::Example; 26 27 use Test::More; 28 29 use parent 'Test::Auto::Plugin'; 30 31 sub tests { 32 my ($self, @args) = @_; 33 34 subtest "testing example plugin", sub { 35 36 ok 1; 37 }; 38 39 return $self; 40 } 41 42 1; 43 44=description 45 46This package provides an abstract base class for creating L<Test::Auto> 47plugins. 48 49=libraries 50 51Test::Auto::Types 52 53=attributes 54 55subtests: ro, req, Subtests 56 57=method tests 58 59This method is meant to be overridden by the superclass, and should perform 60specialized subtests. While not required, ideally this method should return its 61invocant. 62 63=signature tests 64 65tests(Any @args) : Object 66 67=example-1 tests 68 69 package main; 70 71 use Test::Auto; 72 use Test::Auto::Parser; 73 use Test::Auto::Subtests; 74 75 my $test = Test::Auto->new( 76 't/Test_Auto_Plugin.t' 77 ); 78 79 my $parser = Test::Auto::Parser->new( 80 source => $test 81 ); 82 83 my $subtests = Test::Auto::Subtests->new( 84 parser => $parser 85 ); 86 87 # Test::Auto::Plugin::ShortDescription 88 my $example = $subtests->plugin('ShortDescription'); 89 90 $example->tests(length => 200); 91 92=cut 93 94package main; 95 96my $subs = testauto(__FILE__); 97 98$subs = $subs->standard; 99 100$subs->synopsis(sub { 101 my ($tryable) = @_; 102 103 ok my $result = $tryable->result, 'result ok'; 104 105 $result; 106}); 107 108$subs->example(-1, 'tests', 'method', sub { 109 my ($tryable) = @_; 110 111 ok my $result = $tryable->result, 'result ok'; 112 ok $result->isa('Test::Auto::Plugin::ShortDescription'); 113 ok $result->isa('Test::Auto::Plugin'); 114 115 $result; 116}); 117 118ok 1 and done_testing; 119