README
1NAME
2 Test::Expect - Automated driving and testing of terminal-based programs
3
4SYNOPSIS
5 # in a t/*.t file:
6 use Test::Expect;
7 use Test::More tests => 13;
8 expect_run(
9 command => "perl testme.pl",
10 prompt => 'testme: ',
11 quit => 'quit',
12 );
13 expect("ping", "pong", "expect");
14 expect_send("ping", "expect_send");
15 expect_is("* Hi there, to testme", "expect_is");
16 expect_like(qr/Hi there, to testme/, "expect_like");
17
18DESCRIPTION
19 Test::Expect is a module for automated driving and testing of
20 terminal-based programs. It is handy for testing interactive programs
21 which have a prompt, and is based on the same concepts as the Tcl Expect
22 tool. As in Expect::Simple, the Expect object is made available for
23 tweaking.
24
25 Test::Expect is intended for use in a test script.
26
27SUBROUTINES
28 expect_run
29 The expect_run subroutine sets up Test::Expect. You must pass in the
30 interactive program to run, what the prompt of the program is, and which
31 command quits the program:
32
33 expect_run(
34 command => "perl testme.pl",
35 prompt => 'testme: ',
36 quit => 'quit',
37 );
38
39 expect
40 The expect subroutine is the catch all subroutine. You pass in the
41 command, the expected output of the subroutine and an optional comment.
42
43 expect("ping", "pong", "expect");
44
45 expect_send
46 The expect_send subroutine sends a command to the program. You pass in
47 the command and an optional comment.
48
49 expect_send("ping", "expect_send");
50
51 expect_is
52 The expect_is subroutine tests the output of the program like
53 Test::More's is. It has an optional comment:
54
55 expect_is("* Hi there, to testme", "expect_is");
56
57 expect_like
58 The expect_like subroutine tests the output of the program like
59 Test::More's like. It has an optional comment:
60
61 expect_like(qr/Hi there, to testme/, "expect_like");
62
63 expect_handle
64 This returns the Expect object.
65
66SEE ALSO
67 Expect, Expect::Simple.
68
69AUTHOR
70 Leon Brocard, "<acme@astray.com>"
71
72COPYRIGHT
73 Copyright (C) 2005, Leon Brocard
74
75 This module is free software; you can redistribute it or modify it under
76 the same terms as Perl itself.
77
78