1Test::Exit(3) User Contributed Perl Documentation Test::Exit(3)
2
3
4
6 Test::Exit - Test that some code calls exit() without terminating
7 testing
8
10 version 0.11
11
13 use Test::More tests => 4;
14 use Test::Exit;
15
16 is exit_code { exit 75; }, 75, "procmail not found";
17 exits_ok { exit 1; } "exiting exits";
18 never_exits_ok { print "Hi!"; } "not exiting doesn't exit"l
19 exits_zero { exit 0; } "exited with success";
20 exits_nonzero { exit 42; } "exited with failure";
21
23 Test::Exit provides some simple tools for testing code that might call
24 "exit()", providing you with the status code without exiting the test
25 file.
26
27 The only criterion tested is that the supplied code does or does not
28 call "exit()". If the code throws an exception, the exception will be
29 propagated and you will have to catch it yourself. "die()"ing is not
30 exiting for the purpose of these tests.
31
32 Unlike previous versions of this module, the current version doesn't
33 use exceptions to do its work, so even if you call "exit()" inside of
34 an "eval", everything should work.
35
37 exit_code
38 Runs the given code. If the code calls "exit()", then "exit_code" will
39 return a number, which is the status that "exit()" would have exited
40 with. If the code never calls "exit()", returns "undef". This is the
41 Test::Fatal-like interface. All of the other functions are wrappers for
42 this one, retained for legacy purposes.
43
44 exits_ok
45 Tests that the supplied code calls "exit()" at some point.
46
47 exits_nonzero
48 Tests that the supplied code calls "exit()" with a nonzero value.
49
50 exits_zero
51 Tests that the supplied code calls "exit()" with a zero (successful)
52 value.
53
54 never_exits_ok
55 Tests that the supplied code completes without calling "exit()".
56
58 Andrew Rodland <arodland@cpan.org>
59
61 This software is copyright (c) 2013 by Andrew Rodland.
62
63 This is free software; you can redistribute it and/or modify it under
64 the same terms as the Perl 5 programming language system itself.
65
66
67
68perl v5.30.1 2020-01-30 Test::Exit(3)