Skip to content

Commit

Permalink
Use Test::DescribeMe to simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Oct 24, 2024
1 parent a7e86ae commit 97f4ca6
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 99 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Revision history for Geo-Coder-List

0.34
Turn off on-line tests for smokers
Use Test::DescribeMe to simplify tests

0.33 Thu May 16 09:28:54 EDT 2024
Fix test count in t/googleplaces.t
Expand Down
12 changes: 5 additions & 7 deletions t/changes.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Most;
use Test::Needs 'Test::CPAN::Changes';

# if($ENV{AUTHOR_TESTING}) {
# eval 'use Test::CPAN::Changes';
# plan(skip_all => 'Test::CPAN::Changes required for this test') if $@;
# changes_ok();
# } else {
# plan(skip_all => 'Author tests not required for installation');
# }
Test::Needs->import();
# changes_ok();

plan(skip_all => "I don't agree with the author's format for dates");
17 changes: 6 additions & 11 deletions t/comment-spelling.t
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
#!perl
#!usr/bin/env perl

use 5.006;
use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Most;
use Test::Needs { 'Test::Spelling::Comment' => '0.002' };

if($ENV{AUTHOR_TESTING} ) {
eval 'use Test::Spelling::Comment 0.002';
if($@) {
plan(skip_all => 'Test::Spelling::Comment required for testing comment spelling');
} else {
Test::Spelling::Comment->new()->add_stopwords(<DATA>)->all_files_ok();
}
} else {
plan(skip_all => 'Author tests not required for installation');
}
Test::Spelling::Comment->import();
Test::Spelling::Comment->new()->add_stopwords(<DATA>)->all_files_ok();

__DATA__
ArcGIS
Expand Down
13 changes: 4 additions & 9 deletions t/critic.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@

use strict;
use warnings;

use Test::DescribeMe qw(author);
use File::Spec;
use Test::Most;
use Test::Needs 'Test::Perl::Critic';
use English qw(-no_match_vars);

unless($ENV{AUTHOR_TESTING}) {
plan(skip_all => 'Author tests not required for installation');
}

eval "use Test::Perl::Critic";

plan(skip_all => 'Test::Perl::Critic not installed; skipping') if $@;

all_critic_ok();
Test::Perl::Critic::all_critic_ok();
11 changes: 3 additions & 8 deletions t/cv.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@

use strict;
use warnings;
use Test::Most;

if(!$ENV{'AUTHOR_TESTING'}) {
plan(skip_all => 'Author tests not required for installation');
}

eval 'use Test::ConsistentVersion';

plan(skip_all => 'Test::ConsistentVersion required for checking versions') if $@;
use Test::DescribeMe qw(author);
use Test::Most;
use Test::Needs 'Test::ConsistentVersion';

Test::ConsistentVersion::check_consistent_versions();
17 changes: 3 additions & 14 deletions t/dist.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,8 @@
use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Most;
use Test::Needs 'Test::Distribution';

BEGIN {
if($ENV{'AUTHOR_TESTING'}) {
eval {
require Test::Distribution;
};
if($@) {
plan(skip_all => 'Test::Distribution not installed');
} else {
Test::Distribution->import();
}
} else {
plan(skip_all => 'Author tests not required for installation');
}
}
Test::Distribution->import();
3 changes: 2 additions & 1 deletion t/eof.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Needs 'Test::EOF';
use Test::Most;
use Test::Needs 'Test::EOF';

Test::EOF->import();
all_perl_files_ok({ minimum_newlines => 1, maximum_newlines => 4 });
Expand Down
3 changes: 2 additions & 1 deletion t/eol.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Needs 'Test::EOL';
use Test::Most;
use Test::Needs 'Test::EOL';

Test::EOL->import();
all_perl_files_ok({ trailing_whitespace => 1 });
13 changes: 5 additions & 8 deletions t/kwalitee.t
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Most;

if($ENV{AUTHOR_TESTING}) {
eval "use Test::Kwalitee tests => [ qw( -has_meta_yml ) ]";
eval "use Test::Kwalitee tests => [ qw( -has_meta_yml ) ]";

if($@) {
plan(skip_all => 'Test::Kwalitee not installed; skipping') if $@;
} else {
unlink('Debian_CPANTS.txt') if -e 'Debian_CPANTS.txt';
}
if($@) {
plan(skip_all => 'Test::Kwalitee not installed; skipping') if $@;
} else {
plan(skip_all => 'Author tests not required for installation');
unlink('Debian_CPANTS.txt') if -e 'Debian_CPANTS.txt';
}
13 changes: 5 additions & 8 deletions t/noplan.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Most;

if($ENV{'AUTHOR_TESTING'}) {
eval 'use Test::NoPlan qw / all_plans_ok /';
eval 'use Test::NoPlan qw / all_plans_ok /';

if($@) {
plan(skip_all => 'Test::NoPlan required for test verification');
} else {
all_plans_ok();
}
if($@) {
plan(skip_all => 'Test::NoPlan required for test verification');
} else {
plan(skip_all => 'Author tests not required for installation');
all_plans_ok();
}
10 changes: 4 additions & 6 deletions t/pod-synopsis.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Most;
use Test::Needs 'Test::Synopsis';

if($ENV{AUTHOR_TESTING}) {
Test::Synopsis->import();
all_synopsis_ok();
} else {
plan(skip_all => 'Author tests not required for installation');
}
Test::Synopsis->import();
all_synopsis_ok();
14 changes: 5 additions & 9 deletions t/pod.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Most;
use Test::Needs { 'Test::Pod' => '1.22' };

if($ENV{'AUTHOR_TESTING'}) {
# Ensure a recent version of Test::Pod
my $min_tp = 1.22;
eval "use Test::Pod $min_tp";
plan(skip_all => "Test::Pod $min_tp required for testing POD") if $@;
Test::Pod->import();

all_pod_files_ok();
} else {
plan(skip_all => 'Author tests not required for installation');
}
all_pod_files_ok();
16 changes: 5 additions & 11 deletions t/used.t
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#!perl -w

use strict;
use Test::Most;

unless($ENV{'AUTHOR_TESTING'}) {
plan(skip_all => 'Author tests not required for installation');
}
use Test::DescribeMe qw(author);
use Test::Most;
use Test::Needs 'Test::Module::Used';

eval 'use Test::Module::Used';
if($@) {
plan(skip_all => 'Test::Module::Used required for testing all modules needed');
} else {
my $used = Test::Module::Used->new(meta_file => 'MYMETA.yml');
$used->ok();
}
my $used = Test::Module::Used->new(meta_file => 'MYMETA.yml');
$used->ok();
9 changes: 3 additions & 6 deletions t/vars.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
use strict;
use warnings;

use Test::DescribeMe qw(author);
use Test::Most;
use Test::Needs 'Test::Vars';

if($ENV{'AUTHOR_TESTING'}) {
Test::Vars->import();
all_vars_ok(ignore_vars => { '$self' => 0 });
} else {
plan(skip_all => 'Author tests not required for installation');
}
Test::Vars->import();
all_vars_ok(ignore_vars => { '$self' => 0 });

0 comments on commit 97f4ca6

Please sign in to comment.