File: 09-multisession.t

package info (click to toggle)
libtest-www-declare-perl 0.02-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 228 kB
  • sloc: perl: 1,652; makefile: 9
file content (62 lines) | stat: -rw-r--r-- 1,664 bytes parent folder | download | duplicates (6)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!perl
use Test::WWW::Declare::Tester;
use warnings;
use strict;

my @testnames = ('a', 'b', 'c', 'argy mech', 'd', 'f', 'e');
plan tests => 1 + 3 * @testnames;

my @results = run_tests(
    sub {
        session "visit GOOD" => run {
            flow "a" => check {
                get "http://localhost:$PORT/";
                click href qr{good};
                title should equal 'GOOD';
            };

            session "visit FORMY" => run {
                flow "b" => check {
                    get "http://localhost:$PORT/formy";
                    title should equal 'FORMY';
                };
            };

            flow "c" => check {
                title should equal 'GOOD';
            };

            is(mech("visit FORMY")->title, "FORMY", "argy mech");
        };

        session "visit FORMY" => run {
            flow "d" => check {
                title should equal 'FORMY';
            };

            session "visit GOOD" => run {
                flow "e" => check {
                    title should equal 'GOOD';

                    session "visit FORMY" => run {
                        flow "f" => check {
                            title should equal 'FORMY';
                        };
                    };
                };
            };
        };
    }
);

shift @results; # Test::Tester gives 1-based arrays
is(@results, @testnames, "had ".@testnames." tests");
for (1..@testnames) { ok($results[$_-1]{ok}, "test $_ passed") }

for (1..@testnames)
{
    is($results[$_-1]{name}, $testnames[$_-1], "correct test name for test $_");
}

for (1..@testnames) { is($results[$_-1]{diag}, '', "no errors/warnings") }