File: 11-nested-flow-error.t

package info (click to toggle)
libtest-www-declare-perl 0.02-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 232 kB
  • ctags: 121
  • sloc: perl: 1,652; makefile: 9
file content (45 lines) | stat: -rw-r--r-- 1,520 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!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');

# perldelta 5.14, "Stringification of regexes has changed"
my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? "^" : "-xism";
# Carp 1.25 adds a full stop at the end
my $fullstop  = ($Carp::VERSION >= 1.25) ? "." : "";

is($results[1]{diag}, "Flow 'visit good' failed: No link matching (?$modifiers:AAHHH!!!) found at t/11-nested-flow-error.t line 16$fullstop\n", 'nested flow failing only reports once, and gives the right line number');