Our fearless pumpking recently weighed in on test names that assume success.
What he said made a lot of sense.  If a test fails, the message looks all
wrong.

That may compel some people to fix the tests or the modules, but it may confuse
more people.

Here's a patch to Test::Tutorial that improves the test names along those
criteria.  It may be worth adding a few lines on good test names.

Maybe it's worth discussing good testing style, too.

-- c

--- lib/Test/~Tutorial.pod      Tue Oct  9 21:00:06 2001
+++ lib/Test/Tutorial.pod       Tue Oct  9 21:18:18 2001
@@ -124,14 +124,14 @@
 
     use Test::Simple tests => 2;
 
-    ok( defined $ical,              'new() returned something' );
-    ok( $ical->isa('Date::ICal'),   "  and it's the right class" );
+    ok( defined $ical,             'new() should return something' );
+    ok( $ical->isa('Date::ICal'),  '  and it should be Date::ICal or a child' );
 
 So now you'd see...
 
     1..2
-    ok 1 - new() returned something
-    ok 2 -   and it's the right class
+    ok 1 - new() should return something
+    ok 2 -   and it should be Date::ICal or a child
 
 
 =head2 Test the manual
@@ -150,8 +150,8 @@
                              hour => 16, min => 12, sec => 47, 
                              tz => '0530' );
 
-    ok( defined $ical,            'new() returned something' );
-    ok( $ical->isa('Date::ICal'), "  and it's the right class" );
+    ok( defined $ical,            'new() should return something' );
+    ok( $ical->isa('Date::ICal'), '  and it should be Date::ICal or a child' );
     ok( $ical->sec   == 47,       '  sec()'   );
     ok( $ical->min   == 12,       '  min()'   );    
     ok( $ical->hour  == 16,       '  hour()'  );
@@ -162,8 +162,8 @@
 run that and you get:
 
     1..8
-    ok 1 - new() returned something
-    ok 2 -   and it's the right class
+    ok 1 - new() should return something
+    ok 2 -   and it should be Date::ICal or a child
     ok 3 -   sec()
     ok 4 -   min()
     ok 5 -   hour()
@@ -198,8 +198,8 @@
                              hour => 16, min => 12, sec => 47, 
                              tz => '0530' );
 
-    ok( defined $ical,            'new() returned something' );
-    ok( $ical->isa('Date::ICal'), "  and it's the right class" );
+    ok( defined $ical,            'new() should return something' );
+    ok( $ical->isa('Date::ICal'), '  and it should be Date::ICal or a child' );
     is( $ical->sec,     47,       '  sec()'   );
     is( $ical->min,     12,       '  min()'   );    
     is( $ical->hour,    16,       '  hour()'  );
@@ -211,8 +211,8 @@
 you get some more information
 
     1..8
-    ok 1 - new() returned something
-    ok 2 -   and it's the right class
+    ok 1 - new() should return something
+    ok 2 -   and it should be Date::ICal or a child
     ok 3 -   sec()
     ok 4 -   min()
     ok 5 -   hour()
@@ -280,7 +280,7 @@
         my $ical = Date::ICal->new( ical => $ical_str );
 
         ok( defined $ical,            "new(ical => '$ical_str')" );
-        ok( $ical->isa('Date::ICal'), "  and it's the right class" );
+        ok( $ical->isa('Date::ICal'), "  and it should be the right class" );
 
         is( $ical->year,    $expect->[0],     '  year()'  );
         is( $ical->month,   $expect->[1],     '  month()' );
@@ -314,7 +314,7 @@
 itself we're trying out to the name.  So you get results like:
 
     ok 25 - new(ical => '19971024T120000')
-    ok 26 -   and it's the right class
+    ok 26 -   and it should be the right class
     ok 27 -   year()
     ok 28 -   month()
     ok 29 -   day()

Reply via email to