Unit Tests

- Removed useless setup/teardown tests, improving the signal to noise ratio.
This commit is contained in:
Paul Beckingham 2014-06-01 10:28:24 -04:00
parent 1c5a9f70cb
commit e3e21b72a9
15 changed files with 17 additions and 125 deletions

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 5; use Test::More tests => 3;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -38,7 +38,6 @@ if (open my $fh, '>', 'bug.rc')
{ {
print $fh "data.location=.\n"; print $fh "data.location=.\n";
close $fh; close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
} }
# Attempt a blank annotation. # Attempt a blank annotation.
@ -55,11 +54,5 @@ unlike ($output, qr/Command prevented from running/, 'Filter-less write command
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc); unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 13; use Test::More tests => 11;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -43,7 +43,6 @@ if (open my $fh, '>', 'annual.rc')
"report.annual.filter=status:pending\n", "report.annual.filter=status:pending\n",
"report.annual.sort=due+\n"; "report.annual.sort=due+\n";
close $fh; close $fh;
ok (-r 'annual.rc', 'Created annual.rc');
} }
# If a task is added with a due date ten years ago, with an annual recurrence, # If a task is added with a due date ten years ago, with an annual recurrence,
@ -81,11 +80,5 @@ like ($output, qr/No duplicates found/, 'No duplicate UUIDs detected');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data annual.rc); unlink qw(pending.data completed.data undo.data backlog.data annual.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'annual.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -28,7 +28,7 @@
use strict; use strict;
use warnings; use warnings;
use Time::Local; use Time::Local;
use Test::More tests => 17; use Test::More tests => 14;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -42,7 +42,6 @@ if (open my $fh, '>', 'before.rc')
"dateformat=m/d/Y\n", "dateformat=m/d/Y\n",
"dateformat.info=m/d/Y\n"; "dateformat.info=m/d/Y\n";
close $fh; close $fh;
ok (-r 'before.rc', 'Created before.rc');
} }
# Create some example data directly. # Create some example data directly.
@ -56,7 +55,6 @@ if (open my $fh, '>', 'pending.data')
EOF EOF
close $fh; close $fh;
ok (-r 'pending.data', 'Created pending.data');
} }
# Verify data is readable and just as expected. # Verify data is readable and just as expected.
@ -87,11 +85,5 @@ unlike ($output, qr/bar/, 'no bar after 5/1/2009');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data before.rc); unlink qw(pending.data completed.data undo.data backlog.data before.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'before.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 12; use Test::More tests => 10;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -40,7 +40,6 @@ if (open my $fh, '>', 'bulk.rc')
"confirmation=yes\n", "confirmation=yes\n",
"bulk=3\n"; "bulk=3\n";
close $fh; close $fh;
ok (-r 'bulk.rc', 'Created bulk.rc');
} }
# Add some tasks with project, prioriy and due date, some with only due date. # Add some tasks with project, prioriy and due date, some with only due date.
@ -74,11 +73,5 @@ like ($output, qr/Priority\s+M/, 'priority applied to 6');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bulk.rc); unlink qw(pending.data completed.data undo.data backlog.data bulk.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bulk.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 3; use Test::More tests => 1;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'bug.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"confirmation=no\n"; "confirmation=no\n";
close $fh; close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
} }
# Unreported Bug c01: Entering two recurring tasks back to back fails to increment # Unreported Bug c01: Entering two recurring tasks back to back fails to increment
@ -56,11 +55,5 @@ like ($output, qr/Created task 2\./ms, 'Recurring task assigned correct ID.');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc); unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 29; use Test::More tests => 27;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -37,9 +37,7 @@ delete $ENV{'TASKRC'};
if (open my $fh, '>', 'cal.rc') if (open my $fh, '>', 'cal.rc')
{ {
print $fh "data.location=."; print $fh "data.location=.";
close $fh; close $fh;
ok (-r 'cal.rc', 'Created cal.rc');
} }
# Bug: The 'cal' command can fail when provided with challenging arguments. # Bug: The 'cal' command can fail when provided with challenging arguments.
@ -108,10 +106,4 @@ unlike ($output, qr/(?:Assertion failed|Could note recognize|not a valid)/, 'cal
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data cal.rc); unlink qw(pending.data completed.data undo.data backlog.data cal.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'cal.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 5; use Test::More tests => 3;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'bug.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"confirmation=no\n"; "confirmation=no\n";
close $fh; close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
} }
# When a task is modified like this: # When a task is modified like this:
@ -72,11 +71,5 @@ like ($output, qr/Description\s+aaa bbb:ccc ddd\n/, 'properly concatenated');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc); unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 3; use Test::More tests => 1;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -40,7 +40,6 @@ if (open my $fh, '>', 'hang.rc')
"shadow.file=shadow.txt\n", "shadow.file=shadow.txt\n",
"shadow.command=list\n"; "shadow.command=list\n";
close $fh; close $fh;
ok (-r 'hang.rc', 'Created hang.rc');
} }
=pod =pod
@ -74,12 +73,5 @@ if ($@ eq "alarm\n")
# Cleanup. # Cleanup.
unlink qw(shadow.txt pending.data completed.data undo.data backlog.data hang.rc); unlink qw(shadow.txt pending.data completed.data undo.data backlog.data hang.rc);
ok (! -r 'shadow.txt' &&
! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'hang.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 16; use Test::More tests => 14;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'hasnt.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"confirmation=no\n"; "confirmation=no\n";
close $fh; close $fh;
ok (-r 'hasnt.rc', 'Created hasnt.rc');
} }
# 1 # 1
@ -71,7 +70,7 @@ qx{../src/task rc:hasnt.rc add one 2>&1};
qx{../src/task rc:hasnt.rc 7 annotate two 2>&1}; qx{../src/task rc:hasnt.rc 7 annotate two 2>&1};
qx{../src/task rc:hasnt.rc 7 annotate three 2>&1}; qx{../src/task rc:hasnt.rc 7 annotate three 2>&1};
my $output = qx{../src/task rc:hasnt.rc ls description.has:foo 2>&1}; my $output = qx{../src/task rc:hasnt.rc long description.has:foo 2>&1};
like ($output, qr/\n 1/, '1 has foo -> yes'); like ($output, qr/\n 1/, '1 has foo -> yes');
like ($output, qr/\n 2/, '2 has foo -> yes'); like ($output, qr/\n 2/, '2 has foo -> yes');
like ($output, qr/\n 3/, '3 has foo -> yes'); like ($output, qr/\n 3/, '3 has foo -> yes');
@ -80,7 +79,7 @@ like ($output, qr/\n 5/, '5 has foo -> yes');
like ($output, qr/\n 6/, '6 has foo -> yes'); like ($output, qr/\n 6/, '6 has foo -> yes');
unlike ($output, qr/\n 7/, '7 has foo -> no'); unlike ($output, qr/\n 7/, '7 has foo -> no');
$output = qx{../src/task rc:hasnt.rc ls description.hasnt:foo 2>&1}; $output = qx{../src/task rc:hasnt.rc long description.hasnt:foo 2>&1};
unlike ($output, qr/\n 1/, '1 hasnt foo -> no'); unlike ($output, qr/\n 1/, '1 hasnt foo -> no');
unlike ($output, qr/\n 2/, '2 hasnt foo -> no'); # 10 unlike ($output, qr/\n 2/, '2 hasnt foo -> no'); # 10
unlike ($output, qr/\n 3/, '3 hasnt foo -> no'); unlike ($output, qr/\n 3/, '3 hasnt foo -> no');
@ -91,11 +90,5 @@ like ($output, qr/\n 7/, '7 hasnt foo -> yes'); # 15
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data hasnt.rc); unlink qw(pending.data completed.data undo.data backlog.data hasnt.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'hasnt.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 41; use Test::More tests => 39;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -38,7 +38,6 @@ if (open my $fh, '>', 'period.rc')
{ {
print $fh "data.location=.\n"; print $fh "data.location=.\n";
close $fh; close $fh;
ok (-r 'period.rc', 'Created period.rc');
} }
=pod =pod
@ -161,11 +160,5 @@ like ($output, qr/No duplicates found/, 'No duplicate UUIDs detected');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data period.rc); unlink qw(pending.data completed.data undo.data backlog.data period.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'period.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 5; use Test::More tests => 3;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -40,7 +40,6 @@ if (open my $fh, '>', 'range.rc')
"confirmation=no\n", "confirmation=no\n",
"dateformat=m/d/Y\n"; "dateformat=m/d/Y\n";
close $fh; close $fh;
ok (-r 'range.rc', 'Created range.rc');
} }
# Add three tasks, and attempt to list the middle one within a range. # Add three tasks, and attempt to list the middle one within a range.
@ -54,11 +53,5 @@ unlike ($output, qr/three/, 'Missing after range');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data range.rc); unlink qw(pending.data completed.data undo.data backlog.data range.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'range.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 3; use Test::More tests => 1;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'recur.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"confirmation=no\n"; "confirmation=no\n";
close $fh; close $fh;
ok (-r 'recur.rc', 'Created recur.rc');
} }
# Add a recurring task with no due date, look for expected error. # Add a recurring task with no due date, look for expected error.
@ -49,11 +48,5 @@ unlike ($output, qr/Description\s+foo/, 'task not created - missing due date');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data recur.rc); unlink qw(pending.data completed.data undo.data backlog.data recur.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'recur.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 4; use Test::More tests => 2;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -38,7 +38,6 @@ if (open my $fh, '>', 'bug_sort.rc')
{ {
print $fh "data.location=.\n"; print $fh "data.location=.\n";
close $fh; close $fh;
ok (-r 'bug_sort.rc', 'Created bug_sort.rc');
} }
my $setup = "../src/task rc:bug_sort.rc add one 2>&1;" my $setup = "../src/task rc:bug_sort.rc add one 2>&1;"
@ -55,11 +54,5 @@ like ($output, qr/three.*one.*two/msi, 'list did not hang after pri:H on 1');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug_sort.rc); unlink qw(pending.data completed.data undo.data backlog.data bug_sort.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'bug_sort.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 6; use Test::More tests => 4;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'extra.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"confirmation=no\n"; "confirmation=no\n";
close $fh; close $fh;
ok (-r 'extra.rc', 'Created extra.rc');
} }
qx{../src/task rc:extra.rc add foo 2>&1}; qx{../src/task rc:extra.rc add foo 2>&1};
@ -53,11 +52,5 @@ like ($output, qr/bar/, 'Correct annotation');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data extra.rc); unlink qw(pending.data completed.data undo.data backlog.data extra.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'extra.rc', 'Cleanup');
exit 0; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 5; use Test::More tests => 3;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'uuid.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"confirmation=no\n"; "confirmation=no\n";
close $fh; close $fh;
ok (-r 'uuid.rc', 'Created uuid.rc');
} }
# Add a task, dup it, add a recurring task, list. Then make sure they all have # Add a task, dup it, add a recurring task, list. Then make sure they all have
@ -89,11 +88,5 @@ like ($output, qr/No duplicates found/, 'No duplicate UUIDs detected');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data uuid.rc); unlink qw(pending.data completed.data undo.data backlog.data uuid.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'uuid.rc', 'Cleanup');
exit 0; exit 0;