[Jifty-commit] r3816 - in Test-WWW-Declare: lib/Test/WWW t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Aug 6 15:30:20 EDT 2007
Author: sartak
Date: Mon Aug 6 15:30:19 2007
New Revision: 3816
Added:
Test-WWW-Declare/t/10-nested-flow.t
Test-WWW-Declare/t/11-nested-flow-error.t
Modified:
Test-WWW-Declare/ (props changed)
Test-WWW-Declare/lib/Test/WWW/Declare.pm
Test-WWW-Declare/t/04-fail.t
Log:
r29971 at caladan: sartak | 2007-08-06 15:30:09 -0400
Tests for nested flow (with and without failure), fix error handling
Modified: Test-WWW-Declare/lib/Test/WWW/Declare.pm
==============================================================================
--- Test-WWW-Declare/lib/Test/WWW/Declare.pm (original)
+++ Test-WWW-Declare/lib/Test/WWW/Declare.pm Mon Aug 6 15:30:19 2007
@@ -287,16 +287,18 @@
}
elsif ($@) {
if ($IN_FLOW) {
- #$BUILDER->ok(0, $name);
- if ($@ !~ /^Flow '/) {
- Carp::croak "Flow '$name' failed: $@";
+ if ($@ =~ /^Flow '/)
+ {
+ die $@;
}
-
- die "$@\n";
+ die "Flow '$name' failed: $@";
}
$BUILDER->ok(0, $name);
- $BUILDER->diag($@);
+
+ if ($@ !~ /^Flow '/) { # failure occurred during outermost flow
+ $BUILDER->diag("Flow '$name' failed: $@");
+ }
}
else {
$BUILDER->ok(1, $name);
Modified: Test-WWW-Declare/t/04-fail.t
==============================================================================
--- Test-WWW-Declare/t/04-fail.t (original)
+++ Test-WWW-Declare/t/04-fail.t Mon Aug 6 15:30:19 2007
@@ -10,7 +10,7 @@
get "http://localhost:$PORT/";
content should match qr{This is an index};
click href qr{bad};
- content should match qr{This is a good page}i;
+ content should match qr{NOT!}i;
};
flow "should be run" => check {
Added: Test-WWW-Declare/t/10-nested-flow.t
==============================================================================
--- (empty file)
+++ Test-WWW-Declare/t/10-nested-flow.t Mon Aug 6 15:30:19 2007
@@ -0,0 +1,45 @@
+#!perl
+use Test::WWW::Declare::Tester tests => 13;
+use warnings;
+use strict;
+
+my @results = run_tests(
+ sub {
+ session "check logins" => run {
+ flow "visit index good and formy" => check {
+ flow "visit index" => check {
+ get "http://localhost:$PORT/";
+ title should equal 'INDEX';
+ };
+
+ flow "visit good" => check {
+ click href qr/good/;
+ title should equal 'GOOD';
+ };
+
+ flow "visit formy" => check {
+ get "http://localhost:$PORT/formy";
+ title should equal 'FORMY';
+ };
+ };
+ };
+ }
+);
+
+shift @results; # Test::Tester gives 1-based arrays
+is(@results, 4, "had four tests");
+ok($results[0]{ok}, "1st test passed");
+ok($results[1]{ok}, "2nd test passed");
+ok($results[2]{ok}, "3rd test passed");
+ok($results[3]{ok}, "4th test passed");
+
+is($results[0]{name}, "visit index");
+is($results[1]{name}, "visit good");
+is($results[2]{name}, "visit formy");
+is($results[3]{name}, "visit index good and formy");
+
+is($results[0]{diag}, '', 'no errors/warnings');
+is($results[1]{diag}, '', 'no errors/warnings');
+is($results[2]{diag}, '', 'no errors/warnings');
+is($results[3]{diag}, '', 'no errors/warnings');
+
Added: Test-WWW-Declare/t/11-nested-flow-error.t
==============================================================================
--- (empty file)
+++ Test-WWW-Declare/t/11-nested-flow-error.t Mon Aug 6 15:30:19 2007
@@ -0,0 +1,40 @@
+#!perl
+use Test::WWW::Declare::Tester tests => 7;
+use warnings;
+use strict;
+
+my @results = run_tests(
+ sub {
+ session "check logins" => run {
+ flow "visit index good and formy" => check {
+ flow "visit index" => check {
+ get "http://localhost:$PORT/";
+ title should equal 'INDEX';
+ };
+
+ flow "visit good" => check {
+ click href qr/AAHHH!!!/; # this needs to be line 16 (see last test)
+ title should equal 'GOOD';
+ };
+
+ flow "visit formy" => check {
+ get "http://localhost:$PORT/formy";
+ title should equal 'FORMY';
+ };
+ };
+ };
+ }
+);
+
+shift @results; # Test::Tester gives 1-based arrays
+is(@results, 2, "had four tests");
+ok($results[0]{ok}, "1st test passed");
+ok(!$results[1]{ok}, "2nd test failed");
+
+is($results[0]{name}, "visit index");
+is($results[1]{name}, "visit index good and formy");
+
+is($results[0]{diag}, '', 'no errors/warnings');
+
+is($results[1]{diag}, "Flow 'visit good' failed: follow_link couldn't find a link matching (text_regex, (?-xism:AAHHH!!!)) at t/11-nested-flow-error.t line 16\n", 'nested flow failing only reports once, and gives the right line number');
+
More information about the Jifty-commit
mailing list