-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
108 lines (70 loc) · 2.44 KB
/
README
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
NAME
Test2::Plugin::SourceDiag - Output the lines of code that resulted in a
failure.
DESCRIPTION
This plugin injects diagnostics messages that include the lines of
source that executed to produce the test failure. This is a less
magical answer to Damian Conway's Test::Expr module, that has the
benefit of working on any Test2 based test.
SYNOPSIS
This test:
use Test2::V0;
use Test2::Plugin::SourceDiag;
ok(0, "fail");
done_testing;
Produces the output:
not ok 1 - fail
Failure source code:
# ------------
# 4: ok(0, "fail");
# ------------
# Failed test 'fail'
# at test.pl line 4.
IMPORT OPTIONS
show_source
use Test2::Plugin::SourceDiag show_source => $bool;
show_source is set to on by default. You can specify 0 if you want to
turn it off.
Source output:
not ok 1 - fail
Failure source code:
# ------------
# 4: ok(0, "fail");
# ------------
# Failed test 'fail'
# at test.pl line 4.
show_args
use Test2::Plugin::SourceDiag show_args => $bool
show_args is set to off by default. You can turn it on with a true
value.
Args output:
not ok 1 - fail
Failure source code:
# ------------
# 4: ok($x, "fail");
# ------------
# Failure Arguments: (0, 'fail') <----- here
# Failed test 'fail'
# at test.pl line 4.
inject_name
use Test2::Plugin::SourceDiag inject_name => $bool
inject_name is off by default. You may turn it on if desired.
This feature will inject the source as the name of your assertion if
the name has not already been set. When this happens the failure source
diag will not be seen as the name is sufficient.
not ok 1 - ok($x eq $y);
# Failed test 'ok($x eq $y);'
# at test.pl line 4.
note: This works perfectly fine with multi-line statements.
SOURCE
The source code repository for Test2-Plugin-SourceDiag can be found at
http://github.com/Test-More/Test2-Plugin-SourceDiag/.
MAINTAINERS
Chad Granum <exodist@cpan.org>
AUTHORS
Chad Granum <exodist@cpan.org>
COPYRIGHT
Copyright 2017 Chad Granum <exodist@cpan.org>.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See http://dev.perl.org/licenses/